I use willRotateToInterfaceOrientation to exchange views when my iPad rotates. If I have a modal view or an alert view, when my device rotates and changes view, the view swaps and the alert disappears and does not appear again, even if the alert is again βpresentedβ later.
Edit: I narrowed down this issue a bit. When a modal view is presented by a UIModalPresentationFullScreen , the modal view survives.
What can I do to fix this?
Here is my implementation of willRotateToInterfaceOrientation :
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; // // Load an alternate view depending on the orientation // if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { [UIView beginAnimations:@"" context:nil]; [self setView:theLandscapeView]; self.view.bounds = CGRectMake(0, 0, 1024, 768); self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (-90)); [UIView commitAnimations]; }else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { [UIView beginAnimations:@"" context:nil]; [self setView:theLandscapeView]; self.view.bounds = CGRectMake(0, 0, 1024, 768); self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (90)); [UIView commitAnimations]; }else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) { [UIView beginAnimations:@"" context:nil]; [self setView:thePortraitView]; self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (0)); self.view.bounds = CGRectMake(0, 0, 768, 1024); [UIView commitAnimations]; }else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { [UIView beginAnimations:@"" context:nil]; [self setView:thePortraitView]; self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (180)); self.view.bounds = CGRectMake(0, 0, 768, 1024); [UIView commitAnimations]; } }
ios objective-c uikit rotation ipad
Moshe
source share