使用presentViewController时未调用viewDidDisappear [英] viewDidDisappear not called when use presentViewController

查看:1084
本文介绍了使用presentViewController时未调用viewDidDisappear的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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];  
}

在第二个视图控制器中( SendMsgViewController viewDidLoad 我有以下内容:

In the second view controller (SendMsgViewController) viewDidLoad I have the following:

[self presentViewController:picker animated:YES completion:NULL];

其中选择器是 UIImageViewPicker

问题是,当我调用方法 openSendVC 时,会打开一个新控制器,但 viewWillDisappear (第一个viewController)未被调用。

The problem is, when I call the method openSendVC a new controller is opened, but viewWillDisappear (of the first viewController) is not called.

推荐答案

这是正确的行为。以下是来自 viewWillDisappear:的摘录Reference.html#// apple_ref / doc / uid / TP40006926-CH3-SW18rel =nofollow noreferrer> UIViewController API docs

That is the correct behavior. Here's an excerpt about viewWillDisappear: from the UIViewController API docs:


调用此方法以响应从视图层次结构中删除的视图。在实际删除视图之前以及在配置任何动画之前调用此方法。

This method is called in response to a view being removed from a view hierarchy. This method is called before the view is actually removed and before any animations are configured.

呈现新的视图控制器以使其隐藏其他视图控制器不计入视图消失 - 实际上只从视图层次结构中删除(例如,使用类似 popViewControllerAnimated:)。

Presenting a new view controller so that it hides the other view controller doesn't count as the view disappearing—only actually being removed from a view hierarchy does (e.g., with something like popViewControllerAnimated:).

这篇关于使用presentViewController时未调用viewDidDisappear的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆