我对他们的 Controller 有两种看法。
应用程序以 FirstViewController
开始。
然后用一个按钮打开 SecondViewController
。
使用其他按钮,我关闭 SecondViewController
以返回到 FirstViewController
。
有什么方法可以在 FirstViewController
中检测到它已恢复焦点?
编辑:好的,我查看答案并使用 viewWillAppear
但如果我使用 UIModalPresentationFormSheet
则不起作用。
-(IBAction)openSecondView{
SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
screen.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:screen animated:YES];
[screen release];
}
然后用关闭按钮关闭这个 View 。
viewWillAppear
从未调用过。
最佳答案
实现 UIViewController 的 viewWillAppear 方法
- (void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
}
关于objective-c - 确定我何时返回 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7875795/