closures“使用Autolayout”导致应用程序只能在纵向模式下运行
我想我的应用程序与iOS 5兼容,所以我必须在XIB文件中禁用“使用Autolayout”。 整个应用程序被devise为在横向模式下运行。 当禁用自动布局(无论是在iOS 5还是iOS 6)启动应用程序时,应用程序始终以纵向模式启动,并拒绝旋转为横向。
在Info.plist中, Supported Interface Orientations (iPad)
仅被设置为横向。 我究竟做错了什么? 这仅在禁用自动布局之后才会发生。
我能够通过使用Ismael的答案解决iOS 6中的问题。
- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
我能够通过使用下面的代码在iOS 5中修复它。
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); }
添加到您的控制器:
- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
编辑:如果你不想支持肖像,你应该在shouldAutorotate
返回NO
- 如果将UICollectionViewCell子类的contentView.translatesAutoResizingMaskToConstraints设置为“false”?
- 在Swift 3中以编程方式使用ScrollView
- UICollectionViewCell自动布局
- 使用自动布局约束dynamic调整表格视图单元格大小
- Autolayoutdevise适应iPhone 3.5英寸和iPhone 4英寸屏幕尺寸
- UICollectionViewCell systemLayoutSizeFittingSize返回不正确的宽度
- 是否有可能在UIScrollView放大和缩小UIImageView,但坚持自动布局居中?
- 为UIScrollView设置约束
- 如何以编程方式在UIScrollView中用AutoLayout设置子视图?