我已经将我的 Xcode 更新到 4.5,我已经实现了如下的定位方法
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
我在 willRotateToInterfaceOrientation 方法中设置按钮、标签、图像的框架大小
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait )||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown ))
{
// set frame sizes for portait
}
else if(( [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft )||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight ))
{
// set frame sizes for landscape
}
}
但有时旋转模拟器时不会调用此方法,有时模拟器在从另一个 viewController 导航时没有检测到方向。我检查了 info.plist 文件 - 很好。