gpt4 book ai didi

ios - 使用 presentViewController 时未调用 viewDidDisappear

转载 作者:可可西里 更新时间:2023-11-01 03:31:25 29 4
gpt4 key购买 nike

我有一个 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 的)没有被调用。

最佳答案

这是正确的行为。这是关于 viewWillDisappear: 的摘录,来自 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.

呈现一个新的 View Controller 以使其隐藏另一个 View Controller 并不算作 View 消失——只有实际从 View 层次结构中移除才算作 View 消失(例如,使用类似 popViewControllerAnimated: 的东西) .

关于ios - 使用 presentViewController 时未调用 viewDidDisappear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9621346/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com