When is viewwillappear and viewdidappear of the IOS View Controller called?

Source: Internet
Author: User

From: http://stackoverflow.com/questions/5277940/why-does-viewwillappear-not-get-called-when-an-app-comes-back-from-the-backgroun

When Will viewwillappear and viewdidappear be called?

Q:

When I press a View Controller Into A uinavigationcontroller,

1. When will viewwillappear and viewdidappear be triggered?

2. What causes failure to trigger viewwillappear and viewdidappear?

A:

When you call pushviewcontroller: animated to push a View Controller to uinavigationcontroller, uinavigationcontroller automatically calls these methods. Similarly, when you use tabs, uitabbarcontroller directly calls these methods. When you use presentmodalviewcontroller, the method is also called. These methods are also called when a View Controller is added to a window. In these cases, I have never encountered any failure in calling these methods.

Remember, these methods are called only when the Controller pushed or presented is in these specific circumstances. In other cases, it will not be called. For example, you add the view of your view controller as a subview of a view rather than a subview of a window. According to Apple's official documentation, the view controller is only used for full-screen views, typically using the method mentioned above. You can ignore Apple's suggestion to associate one View Controller with another view as a subview, but you need to manually call viewwillappear and viewdidappear of the nested controller in the View Controller as the container.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.