gpt4 book ai didi

ios - 呈现登录 UINavigationController 显示黑屏

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

我的 iOS 应用程序需要用户身份验证,当用户未通过身份验证时,应用程序应显示一个用户可以登录的 ViewController。该屏幕还为用户提供了创建帐户的选项,因此整个登录屏幕(和可选的注册屏幕)都是使用以编程方式显示的 UINavigationController 进行设置的。

使用以下代码显示登录屏幕:

- (void)promptCredentials{
dispatch_async(dispatch_get_main_queue(), ^{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *loginScreenNav = [storyboard instantiateViewControllerWithIdentifier:@"LoginNavigationController"];
[loginScreenNav setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:loginScreenNav animated:YES];
});
}

但是,当调用此方法时,应用程序会导航到黑屏 enter image description here 。以编程方式向用户呈现不同 ViewController 的正确方法是什么?我发现了几个与此类黑屏相关的问题,但是,没有一个答案对我有用。我的应用程序在 iOS 8.2 上运行。

最佳答案

您需要创建一个 UIViewcontroller 并将其设置为您的 UINAvigationController 的根 Controller 。

presentModalViewController 从 ios6 开始被弃用,尝试使用 presentViewController。

UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginNavigationController"];

UINavigationController *loginScreenNav = [[UINavigationController alloc] initWithRootViewController:vc];

[self presentViewController:loginScreenNav animated:YES];

关于ios - 呈现登录 UINavigationController 显示黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29328272/

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