use*_*993 3 view switching uinavigationcontroller ios appdelegate
我希望我的应用程序在处于非活动状态时返回登录屏幕(导航控制器中的根视图).
我在applicationWillResignActive和appdelegate.m无法识别self.navigationController
我试图在appdelegate.h中使用ctrl拖动在故事板中制作出口或导航控制器,但它不会让我.
那么有人知道如何在它变为非活动状态时切换到特定视图吗?
您可以在应用程序返回时通过在方法applicationWillEnterForeground或applicationDidBecomeActive中执行该代码来显示原始uiviewcontroller
快速代码
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
[navigationController popToRootViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我肯定不是唯一或最好的方法,但它在技术上有效
| 归档时间: |
|
| 查看次数: |
3605 次 |
| 最近记录: |