Reputation: 5834
I have developed an app without storyboard.
I have a functionality of Logout. When user click on logout then I have to redirect him to the sign in page and clear all navigation stack and make sign in page root view.
I am trying with this code but using this my app crashes:
SignUpVC *main = [[SignUpVC alloc]initWithNibName:@"SignUpVC" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:main];
[self presentViewController:main animated:NO completion:nil];
Upvotes: 1
Views: 443
Reputation: 7804
To change the root view of the application you can do it in this way
SignUpVC *main = [[SignUpVC alloc]initWithNibName:@"SignUpVC" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:main];
[[UIApplication sharedApplication].keyWindow setRootViewController:navController];
Upvotes: 2