gpt4 book ai didi

ios - 从 appDelegate 呈现 ViewController

转载 作者:行者123 更新时间:2023-11-29 10:38:38 26 4
gpt4 key购买 nike

每次应用程序从 applicationDidEnterBackground 方法中的后台返回时,我都需要从 appDelegate 显示一个 ViewController。

*securityCheck 提示用户输入密码,这与 iOS 中的普通密码非常相似。验证密码后,我在 securityCheck 中调用 dimissViewControllerAnimated,我只剩下空白的 UINavigationController,因为 View 是从 appDelegate 呈现的,我没有记录谁呈现了 View ,所以我不能 popToRootViewController。

我的问题是如何正确关闭 SecurityCheckViewController,以便它显示用户在应用程序进入后台之前所在的 ViewController。

这是我的代码:

该方法在AppDelegate.m中调用

- (void)securityCheck {

SecurityCheckViewController *securityCheck = [[SecurityCheckViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:securityCheck];

[securityCheck presentedByAppDelegate:YES];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setRootViewController:navigationController];
[self.window makeKeyAndVisible];
}

然后在 SecurityCheckViewController.m 里面我有

- (void)unlockWasSuccessfulForPadLockScreenViewController:(ABPadLockScreenViewController *)padLockScreenViewController {

[self.appDelegate securityCheckDone];
[padLockScreenViewController dismissViewControllerAnimated:YES completion:nil];

NSLog(@"Sucsessfull Unlock");I'm
}

最佳答案

现在

- (void)securityCheck {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
SecurityCheckViewController *securityCheck = [storyboard instantiateViewControllerWithIdentifier:@"securityCheckView"];
[self.window.rootViewController presentViewController:securityCheck animated:NO completion:nil];
}

关闭

[self dismissViewControllerAnimated:YES completion:nil];

关于ios - 从 appDelegate 呈现 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25675162/

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