在app中仅更改一个UIViewController的UIInterfaceOrientation [英] Change UIInterfaceOrientation for only one UIViewController in app
问题描述
我有一个iPhone应用程序,其结构类似于导航控制器带表 - >下一个视图控制器带表 - > QLPreviewController。通过在第一个视图控制器(带导航控制器)中的表格单元格中出现新视图控制器与另一个表格,通过点击它的单元格显示QLPreviewController。
I have an iPhone app with structure like "Navigation controller with table -> next view controller with table -> QLPreviewController". By tap in cell of table in first view controller(with navigation controller) appears new view controller with another table, by tap in cell of it shows QLPreviewController.
例如:在第一个表中有组,在第二个表中 - 所选组的文档和用于预览所选文档的QLPreviewController。
For example: In first table there are Groups, in second table - Documents of selected Group, and QLPreviewController for previewing selected Document.
我的应用程序中的每个ViewController必须仅以纵向(非上部)方向显示,但QLViewController也必须支持横向(左右)。
Every ViewController in my app must to appear only in Portrait(not upside) orientation, but QLViewController must also support Landscape(left and right).
我在QLPreviewController出现之前将标志canRotate设置为YES。在AppDelegate中如果 canRotate == YES
我为任何Orientation返回YES,以旋转QLPreviewController。方法previewControllerWillDismiss中的QLPreviewControllerDelegate:(QLPreviewController *)控制器设置标志canRotate返回NO。但是如果在QLPreviewController解除之前方向是Landscape,那么我的所有ViewController都会保持横向方向...
I'm setting flag canRotate to YES before QLPreviewController appear. In AppDelegate if canRotate == YES
I'm return YES for any Orientation, to rotate QLPreviewController. QLPreviewControllerDelegate in method previewControllerWillDismiss:(QLPreviewController *)controller sets flag canRotate back to NO. But if orientation was Landscape before QLPreviewController dismiss, all of my ViewControllers stay in Landscape orientation...
如何在WillDismiss方法中将ViewController旋转回Portrait方向?
How can I rotate ViewController back to Portrait orientation in WillDismiss method?
推荐答案
我在申请表上做的事情(或多或少与你的一样)是:
What I did on my application (its more or less like yours) was:
1)为两个屏幕设置shouldRotate 是
。
1) Set shouldRotate Yes
for both screens.
2)对于第一个视图,设置以下掩码:
2) For the first view set the following mask:
return UIInterfaceOrientationMaskPortrait
对于第二个View put:
For the second View put:
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
这篇关于在app中仅更改一个UIViewController的UIInterfaceOrientation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!