Answer the question
In order to leave comments, you need to log in
How to change initial View Controller?
Good afternoon, I have a login form in the application, I need to change the intial View Controller in the storyboard after user authorization. That is, after authorization, the initial page would not be a login form, a user profile.
Answer the question
In order to leave comments, you need to log in
The best way would be to initialize the view controller not through the storyboard, but in the method
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
1) In the Storyboard , provide the association ID between the authorization controller and the user profile.
2) In authorization controller, if user is authorized, use
- performSegueWithIdentifier:sender:
I took the advice of ManWithBear and made this sketch
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let logined = true
var vc: UIViewController?
if !logined {
vc = storyboard.instantiateViewControllerWithIdentifier("loginVC")
} else {
vc = storyboard.instantiateInitialViewController()
}
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = vc
window?.makeKeyAndVisible()
return true
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question