我有一个具有此方法的UIViewController:

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    NSLog(@"DISAPPEAR");
    lastKnownOrientation = [self interfaceOrientation];
}


-(void)openSendVC{
    SendMsgViewController *vc = [[SendMsgViewController alloc]initWithNibName:@"SendMsgViewController" bundle:nil];
    [self.navigationController pushViewController:vc animated:NO];
}

在第二个 View Controller (SendMsgViewController)viewDidLoad中,我具有以下内容:
[self presentViewController:picker animated:YES completion:NULL];

其中picker是UIImageViewPicker

问题是,当我调用方法openSendVC时,将打开一个新的 Controller ,但未调用viewWillDisappear(第一个viewController的)。

最佳答案

那是正确的行为。这是UIViewController API docs中的viewWillDisappear:的摘录:



呈现一个新的 View Controller 以使其隐藏另一个 View Controller 不会被视为 View 的消失-只是实际上是从 View 层次结构中删除的(例如,使用popViewControllerAnimated:之类的东西)。

10-08 07:46
查看更多