Reputation: 5722
The logic goes like this:
The app delegate triggers the main viewcontroller (UIViewController, nothing fancy). code checks if we need to go to a different viewcontroller without displaying the current one. I use the code:
let vc = storyboard!.instantiateViewControllerWithIdentifier("NextViewController")
self.presentViewController(vc, animated: true, completion: nil)
I can get the right behavior in viewDidAppear which is too late because we are already showing the content. Moving the code in viewWillAppear complains about the fact that the vc is not in the view hierarchy yet.
What is the best approach? Should I start using a navigation controller?
Upvotes: 0
Views: 45
Reputation: 31
If you decide to use a UINavigationController you can perform a check in viewDidLoad:
method of the first VC and perform a segue without animation to the next view controller.
Such segue would be done like this this
.h:
#import <UIKit/UIKit.h>
@interface PushNoAnimationSegue : UIStoryboardSegue
@end
.m:
#import "PushNoAnimationSegue.h"
@implementation PushNoAnimationSegue
- (void)perform{
[[[self sourceViewController] navigationController] pushViewController:[self destinationViewController] animated:NO];
}
@end
Upvotes: 0
Reputation: 143
Have you try to do your check in your app delegate and do something like this ? :
let vc = storyboard!.instantiateViewControllerWithIdentifier("NextViewController")
self.window.setRootViewController(vc)
Upvotes: 1