[英]Popping a non-root view controller on app launch (iOS)
I have a working application with a UITableViewController
as a root view controller. 我有一个使用
UITableViewController
作为根视图控制器的工作应用程序。
I need to pop a simple log-in screen on app launch, 我需要在应用启动时弹出一个简单的登录屏幕,
and i can't set it as root view controller because it's against the project properties. 我不能将其设置为根视图控制器,因为它违反了项目属性。
also, im using storyboard. 此外,即时通讯使用情节提要。
Simply, in root view controller (UITableViewController in your case) viewDidAppear's method, present log-in screen as modalViewController. 只需在根视图控制器(您的情况下为UITableViewController)中的viewDidAppear的方法中,将登录屏幕显示为modalViewController。 You need to set the Identifier for your ViewController first.
您需要先为您的ViewController设置标识符。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard"
bundle:nil];
LoginViewController *lgn = [storyboard instantiateViewControllerWithIdentifier:@"LoginView"];
[self presentViewController:lgn animated:YES completion:NULL];
Use your own storyboard and viewController names. 使用您自己的情节提要和viewController名称。
In App Delegate 应用内委托
loginViewController = [[BANLoginViewController alloc] initWithNibName:@"BANLoginViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
[window addSubView:[navController view]];
[window makeKeyAndVisible];
And in the BANLoginViewController
you could check if the user is logged in or not and then initialise the main storyboard. 在
BANLoginViewController
您可以检查用户是否登录,然后初始化主故事板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.