I wanted this:
MapVC is a Map in full screen.
When I press a button, it opens PopupVC (not in full screen) above the map.
When I press a button in PopupVC, it returns to MapVC, and then I want to execute viewDidAppear.
I did this:
MapVC.m: in the button action, a segue programmatically, and set delegate
- (void) buttonMapAction{
PopupVC *popvc = [self.storyboard instantiateViewControllerWithIdentifier:@"popup"];
popvc.delegate = self;
[self presentViewController:popvc animated:YES completion:nil];
}
- (void)dismissAndPresentMap {
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"dismissAndPresentMap");
//When returns of the other view I call viewDidAppear but you can call to other functions
[self viewDidAppear:YES];
}];
}
PopupVC.h: before @interface, add the protocol
@protocol PopupVCProtocol <NSObject>
- (void)dismissAndPresentMap;
@end
after @interface, a new property
@property (nonatomic,weak) id <PopupVCProtocol> delegate;
PopupVC.m:
- (void) buttonPopupAction{
//jump to dismissAndPresentMap on Map view
[self.delegate dismissAndPresentMap];
}