Change UIInterfaceOrientation for only one UIViewController in app

纵饮孤独 提交于 2019-12-02 12:38:16

问题


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.

For example: In first table there are Groups, in second table - Documents of selected Group, and QLPreviewController for previewing selected Document.

Every ViewController in my app must to appear only in Portrait(not upside) orientation, but QLViewController must also support Landscape(left and right).

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...

How can I rotate ViewController back to Portrait orientation in WillDismiss method?


回答1:


What I did on my application (its more or less like yours) was:

1) Set shouldRotate Yes for both screens.

2) For the first view set the following mask:

return UIInterfaceOrientationMaskPortrait

For the second View put:

return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;


来源:https://stackoverflow.com/questions/13357156/change-uiinterfaceorientation-for-only-one-uiviewcontroller-in-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!