DidRotateFromInterfaceOrientation not working when spinning?

Possible duplicate:
ViewController not responding to didRotateFromInterfaceOrientation

I am having problems with the didRotateFromInterfaceOrientation method, which does not work in one of my viewcontroller subclasses.

I have an iPad application with UISplitViewController as the main view. On the part side, I use a "hidden" (without a toolbar, navigator) navigation controller for lazy switching views. The ViewController I want to catch isRotateFromInterfaceOrientation on is at two levels in the navcontroller hierarchy. (None of this should change, but I will include this information in case there is any specific case that I do not know about)

I have:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } // This doesn't work. :( - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { NSLog(@"Rotate Go!"); } 

The view rotates just fine, but didRotateFromInterfaceOrientation never fires.

Any idea what I am missing?

+7
source share
2 answers

Well, I never figured out why the events didn’t shoot, but I figured out a workaround:

In the two methods of the UISplitViewController delegate, splitViewController:willHideViewController:withBarButtonItem:forPopoverController: and splitViewController:willShowViewController:invalidatingBarButtonItem: I detect whether or not my view is visible, and then follow my rotation logic here.

0
source

If your UIViewController is a child in some root view, IB does not add it as a child controller to the default root controller. The easiest way to solve this problem is to change the root controller:

 - (void)viewDidLoad { [super viewDidLoad]; [self addChildViewController:(UIViewController*) self.yourChildController]; } 

That should do the trick. Now your child controller will receive both:

 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; 

and

 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; 

messages.

+5
source

All Articles