我在 iOS6 中遇到自动旋转和方向问题。他们不像以前在 iOS5 中那样工作。这是示例代码。
implementation mainProgram
// view controller is defined in landscape mode (.xib file)
// The preferredInterfaceOrientationForPresentation and supportedInterfaceOrientations have not been defined because they give me problems with getting the orientation right of other calling classes
-(IBAction)somButtonPressed:(id)sender{
[self presentViewController:inputText animated:NO completion:nil];
}
@end
/////////////////////////////////////////////////////////
// This has has several UITextField
// The view of this controller is defined as landscape in .xib
implementation inputText
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (BOOL)shouldAutorotate {
return YES;
}
#if 0 // Disabled
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationLandscapeRight;
}
#endif
#if 1 // Enabled
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeRight;
}
#endif
@end
问题/观察: 1. 如果在 inputText 中启用了supportedInterfaceOrientations,返回值为UIInterfaceOrientationLandscapeRight,程序将失败,说preferredInterfaceOrientationForPresentation 试图设置为无效的方向,即使与supportedInterfaceOrientations 完全相同
- 当我尝试在 inputText 的 UITextField 之一上输入文本时,键盘以纵向模式出现,而不是 LandscapeRight。inputText 控制器的视图在 LandscapeRight 方向上很好。
在我看来,它们都是 ios6 中的错误。有没有其他人遇到过这些问题?