Possible Duplicate:
ViewController not responding to didRotateFromInterfaceOrientation
I'm having trouble with the didRotateFromInterfaceOrientation method not firing in one of my viewcontroller subclasses.
I have an iPad app w/ UISplitViewController as the main view. On the Detail side, I'm using a "hidden" (no toolbar,navbar) navigation controller for lazy view switching. The ViewController I'm wanting to catch didRotateFromInterfaceOrientation on is two levels deep in the navcontroller hierarchy. (None of this should make a difference, but I'm including this info in case there's some particular case that I don't 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'm missing?
If your UIViewController is a child in some root view then IB does not add it as a child controller to the root controller by default. The easiest way to address this is to modify your root controller:
- (void)viewDidLoad
{
[super viewDidLoad];
[self addChildViewController:(UIViewController*) self.yourChildController];
}
This should do the trick. Now your child controller will be receiving both:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
and
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
messages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With