我尝试了以下方法来强制在一个视图中横向显示:
我尝试了以下方法来强制在一个视图中横向显示:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
- (BOOL)shouldAutorotate{
return YES;
}
都没起作用。请注意,我在模拟器和iPad上测试。
谢谢
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
。 苹果提供了两个非常相似但非常不同的枚举:UIDeviceOrientation 和 UIInterfaceOrientation。设备属性是只读的,因为您无法强制物理设备更改方向!statusBarOrientation 是可写的,并且将执行您想要使用 setValue:forKey: 进行的操作。 - Dan Jackson