
如果用户旋转设备,这是正常的.但是,如果设备保持在纵向模式,则supportedInterfaceOrIEntations方法不会被调用,除非用户手动旋转设备.
根据文档,似乎我应该能够调用[UIVIEwController attemptRotationToDeviceOrIEntation],但是这没有任何效果(supportedInterfaceOrIEntations从不被调用,屏幕不旋转).
我发现其他人已经发布了各种解决方法来尝试解决这个问题,但是没有人在我的测试中工作.我怀疑他们可能在iOS 5.0中工作,但不是iOS 6.0.
我在根视图控制器的shouldautorotate方法中返回YES.
解决方法 首先,如果您要以横向模式呈现您的UIVIEwController,则可能会有用.- (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation{ return UIInterfaceOrIEntationLandscapeleft | UIInterfaceOrIEntationLandscapeRight;} 另外,很多依赖于你的UIVIEwController嵌入在哪个控制器中.
例如,如果在UINavigationController内部,那么您可能需要将该UINavigationController子类化以覆盖这样的方向方法.
子类UINavigationController(层次结构的顶层vIEwcontroller将控制方向).需要将其设置为self.window.rootVIEwController.
- (BOol)shouldautorotate { return self.topVIEwController.shouldautorotate; } - (NSUInteger)supportedInterfaceOrIEntations { return self.topVIEwController.supportedInterfaceOrIEntations; } 从iOS 6起,UINavigationController不会要求其UIVIEwControllers进行定向支持.因此,我们需要对它进行子类化.
注意 :
每当Push *** 作完成时,将始终调用shouldautorotate和supportedInterfaceOrIEntations方法调用UINavigationController.
总结以上是内存溢出为你收集整理的ios – 在supportInterfaceOrientations更改时如何通知系统?全部内容,希望文章能够帮你解决ios – 在supportInterfaceOrientations更改时如何通知系统?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)