0

我陷入了困境:看看这张照片: 在此处输入图像描述

我有 soundPlayerVC 作为 pageContentVC 的 childeViewController。

soundPlayerVC 呈现邮件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];
}

但是当我点击backButton时,popViewController不起作用,因为navigationController已经被清空了!!

这是怎么发生的?有人可以解释吗?

4

1 回答 1

1

我找到了解决方案:那是因为我没有在正确的视图控制器中弹出视图控制器。

pageContentVCbookRootVCsobookRootVC的子节点,负责pageContnetVC从 navigationController 堆栈中移除。

我创建了一个协议并添加了一个委托属性pageContnetVC并分配bookRootVCpageContnetVC

protocol DismissViewControllerDelegate <NSObject>
- (void)popViewController;
@end

bookRootVC实现协议:

#pragma mark pop view controller delegate
- (void)popViewController
{
    [self.navigationController popViewControllerAnimated:YES];
}

viewDidLoad

 self.pageViewController.delegate = self;

最后 backButtonpageContentVC调用它的委托来从 navigationController 中删除这个视图。

就这样!

于 2014-01-06T19:38:13.600 回答