[英]I can't push the loginViewcontroller with navigationController on self.window
I have point a pageViewController
as the rootViewController
,and then I wanna display a login view above the pageViewController
if not sign in. 我已经将
pageViewController
指向rootViewController
,然后如果rootViewController
,我想在pageViewController
上方显示一个登录视图。
NLLoginViewController *loginVC = [[NLLoginViewController alloc]init];
UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:loginVC];
[self.window addSubview:navigation.view];
You should do the following thing 你应该做以下事情
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
NLLoginViewController *loginVC = [[NLLoginViewController alloc]initWithNibName:@"NLLoginViewController" bundle:nil];
PageViewController *pageVC = [[PageViewController alloc]initWithNibName:@"PageViewController" bundle:nil];
UINavigationController *navigation
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"is_SignedIn"]))
navigation = [[UINavigationController alloc]initWithRootViewController:logindVC];
else
navigation = [[UINavigationController alloc]initWithRootViewController:pageVC];
self.window.rootViewController = navigation;
After that In login view controller, you have to set 之后,在登录视图控制器中,您必须设置
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_SignedIn"];
plz try this 请尝试这个
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"yourStorybordname" bundle:nil];
NLLoginViewController *loginvc= [storyboard instantiateViewControllerWithIdentifier:@"yourviewControllerid"];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:loginvc];
self.window.rootViewController = navController;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.