简体   繁体   中英

What's the order between pushing a view and viewWillAppear?

I made a viewController class which has a button, an input and a label. What I want to implement is that when user click the button, a new view will be pushed and the input text will be showed in the label. I used UINavigationController to memorize the text in input and set the logic in 'pushNext', which is the IBAction of the button, and the viewWillAppear method is used to put the text stored in UINavigationController into label.

I used NSLog to track the proc, and found that viewWillAppear always be called earlier than pushNext? But when I run the example code in my book, the called order was oppsite!

Why? Is there any attention to use these two methods?

The order should be

viewDidLoad
viewWillAppear
viewDidAppear

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