Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stopping ios5 lifecycle events automatically being called

All of my view controllers extend my own BaseViewController : UIViewController, and in this i have overridden

- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
    return NO;
}

However, iOS 5 simulator has decided to ignore this and continues to call my viewWillAppear etc methods on my nested UIViewController hierarchy.

I've done the same in another project and it worked fine. Is there something else i'm missing to get it to listen to me?

like image 710
bandejapaisa Avatar asked Dec 12 '11 23:12

bandejapaisa


1 Answers

Turns out you also have to use this method too:

UIViewController addChildViewController

So by doing this:

[self addChildViewController:_browserViewController];
[browserView addSubview:_browserViewController.view];
[_browserViewController didMoveToParentViewController:self]; 

..and returning NO from automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers

... it stops the view lifecycle methods being called twice.

like image 82
bandejapaisa Avatar answered Oct 07 '22 00:10

bandejapaisa