简体   繁体   English

在应用启动(iOS)时弹出非根视图控制器

[英]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.

相关问题 弹出到根视图控制器时崩溃 - Crash when popping to root view controller iOS:在控制台上获取此消息(而不是错误) - 应用程序窗口应在应用程序启动结束时具有根视图控制器 - iOS: Getting this message (not an error) on console- Application windows are expected to have a root view controller at the end of application launch 用于在iOS 7上弹出视图控制器崩溃的平移手势 - Pan gesture used for popping view controller crashing on iOS 7 iOS-使用MKMapView弹出并推送视图控制器时发生意外崩溃 - iOS - Unexpected crash when popping and pushing a view controller with a MKMapView 应用程序窗口应该在应用程序启动结束时有一个根视图控制器(Iphone 应用程序) - Application windows are expected to have a root view controller at the end of application launch (Iphone App) 在iPhone应用程序中弹出视图控制器时出现横向动画错误 - Landscape animation bug when popping view controller in iPhone app 弹出项目的第一个视图控制器 - Popping to first view controller of the project iOS:从任何地方返回到根视图控制器 - iOS: return to root view controller from anywhere iOS扩展UIWindow禁用了根视图控制器? - iOS Extending UIWindow disabled the root view controller? 应用程序窗口在应用程序启动结束时有望具有一个根视图控制器 - Application windows are expected to have a root view controller at the end of application launch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM