I have stucked in scenario: look at this picture:
I have soundPlayerVC as childeViewController of pageContentVC.
soundPlayerVC Present mail modalViewController:
- (IBAction)emailStory:(id)sender {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
Anecdote *anecdote = (Anecdote *)story;
[picker setSubject:anecdote.name];
[picker setMessageBody:[SearchHandler removeMarkupsFromPageText:anecdote.detail] isHTML:NO];
[self.parentViewController presentViewController:picker animated:YES completion:nil];
}
#pragma mark - mail compose delegates
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[controller dismissViewControllerAnimated:YES completion:nil];
}
but when I tap on backButton, popViewController doesn't work, because navigationController has been emptied!!
HOW THIS HAPPENED? could someone explain?
I found the solution: that was because of I didn't popViewController in the right viewController.
pageContentVC
is child ofbookRootVC
sobookRootVC
is responsible of removingpageContnetVC
from navigationController Stack.I created a protocol and added a delegate property
pageContnetVC
and assignedbookRootVC
as delegate ofpageContnetVC
bookRootVC
implement the protocol:in
viewDidLoad
and finally backButton in
pageContentVC
call its delegate to remove this view from navigationController.thats all!