简体   繁体   中英

viewDidAppear called before applicationDidBecomeActive

I'm just starting an iphone app with a initial viewcontroller which is embeded in a navigationController and have a pushSegue to a tabBarController .

Whenever I run the simulator, viewDidAppear of the initial viewController called before applicationDidBecomeActive being called.

Isn't it suppose to enter applicationDidBecomeActive in appdelegate before any viewController load?

In iOS8, viewDidLoad used to run before applicationDidBecomeActive. However, in iOS9, I'm seeing that with the same code, applicationDidBecomeActive is running before viewDidLoad. Strange.

Yes it's ok I think you are just little confuse. How an application will become active until it's load it's view.

When you first time launch the application will call the method in order -

From App Delegate -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

From View Controller -

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

- (void)viewDidLoad

- (void)viewWillAppear:(BOOL)animated

- (void)viewDidAppear:(BOOL)animated

From App Delegate -

- (void)applicationDidBecomeActive:(UIApplication *)application

applicationDidBecomeActive is a delegate located in your Application Delegate and there's no guarantee that it will be called before any other UIViewController delegates (viewWillAppear, viewDidLoad etc.). If you want to make any logic before loading of any other view controller method is called, you may want to use application:didFinishLaunchingWithOptions: .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM