Views do not rotate correctly
I use an IF statement to detect when the orientation of a device changes, and when it does, a new view is displayed, one portrait, the other landscape. The only problem is, if I rotate from portrait to landscape, and the landscape view shows, it has not rotated all of the way. It开发者_JAVA百科 is still in portrait, 90 degrees off of what it should be. Thanks for your help!
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//portrait
self.view = portrait;
} else {
//landscape
self.view = landscape;
}
}
There is sample code provided by Apple for this here.
You might be able to fix it by storing the destination orientation during willRotateToInterfaceOrientation, then pushing your new view afterwards on didRotateFromInterfaceOrientation.
精彩评论