IOS 5.0 View Lifecycle Issues

I am facing the strange behavior of my custom view controller subclass on iOS 5.0. I did not use the standard navigation controller etc. in my iPad app, but I also All view controllers are provided-this is why I need to manually call the -viewWillAppear and viewDidAppear methods.

Since iOS 5.0, it seems that when adding the view controller’s view as a subview, These methods are automatically called on the view controller instance of the view. This means that in my case these methods are called twice.

Any suggestions? Besides creating my own view lifecycle methods and rewriting the entire application?

Thank you very much!

Add the following to your UIViewController to disable automatic calls to those -viewWill… and -viewDid… Method:

-(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
return NO;
}

This will force iOS 5.0 to Stop calling these methods when adding subviews, and will not break anything in iOS 4.x. As long as I continue to support devices on iOS 4.x, I will use this method. Once I give up support for iOS 4, I will refactor my code to use the new method of swapping view controllers (as described in the Session 102 video posted by hypercrypt).

I am facing on iOS 5.0 Strange behavior of my custom view controller subclass. I did not use standard navigation controllers etc. in my iPad app, but I also provide all view controllers myself-this is what I need to call manually-viewWillAppear and viewDidAppear The reason for the method.

Since iOS 5.0, it seems that when adding a view controller’s view as a subview, these methods are automatically called on the view controller instance of the view. This means In my case these methods are called twice.

Any suggestions? Besides creating my own view lifecycle methods and rewriting the entire application?

Thank you very much!

Add the following to your UIViewController to disable automatically calling those -viewWill… and -viewDid… methods:

-(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
return NO;
}

This will force iOS 5.0 to stop calling these methods when adding child views, and will not Destroy anything in iOS 4.x. As long as I continue to support devices on iOS 4.x, I will use this method. Once I give up support for iOS 4, I will refactor my code to use swap view control The new method of the device (as described in the Session 102 video released by hypercrypt).

Leave a Comment

Your email address will not be published.