【发布时间】:2012-06-27 02:57:11
【问题描述】:
如果应用程序之前在后台,当调用 applicationDidBecomeActive 时,我希望我的故事板的初始视图控制器是当前控制器。
我用过:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[self.window makeKeyAndVisible];
}
当我重新启动应用程序时,rootViewController 内的loginAciton 仍然被调用,但无法呈现下一个控制器。没有错误,就像什么都没发生一样。
- (IBAction)loginAciton:(id)sender
{
id controller = [self.storyboard instantiateViewControllerWithIdentifier:@"Navigation"];
[self presentModalViewController:controller animated:YES];
}
为什么?
PS。我的 rootViewController 不是 UINavigationController。
感谢您的任何回复。
【问题讨论】:
-
[self.storyboard instantiateViewControllerWithIdentifier:@"Navigation"]返回什么? -
你能用
-performSegueWithIdentifier:sender:代替吗? -
返回 UINavigationController。
-performSegueWithIdentifier:sender:和presentModalViewController之间有什么区别? -
对不起,我想我不是很清楚,使用 Debugger 或 NSLog() 并获取实际返回值。如果
-presentModalViewController:animated:失败,则不会返回 UINavigationController 对象。-instantiateViewControllerWithIdentifier:和-performSegueWithIdentifier:sender:使用不同的标识符。如果您在使用一个标识符时遇到问题,那么另一个可能会起作用。
标签: iphone ios storyboard