我希望我的应用程序在不活动时返回登录屏幕(这是导航 Controller 中的 Root View )。
我在 applicationWillResignActive 中,appdelegate.m 无法识别 self.navigationController
我试图在 Storyboard中使用 ctrl 拖动在 appdelegate.h 中创建一个 socket 或导航 Controller ,但它不允许我这样做。
那么有人知道如何让它在不活动时切换到特定 View 吗?
最佳答案
您可以在应用程序返回时通过在方法 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];
}
我确信这不是唯一或最好的方法,但它在技术上是可行的
关于Ios:当应用程序进入非事件状态时,如何让我的应用程序返回 Root View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12064667/