简体   繁体   中英

Pushing a View Controller in a specific orientation

The main UIViewController ( A ) displays another UIViewController ( B ) when the devices rotates to Landscape mode. So rotating the device to landscape while on A presents B modally and rotating back to portrait on B dismisses B and goes back to A .

While on B I want to push another UIViewController ( C ) into A 's stack. C can only be displayed in portrait though. I am aware that this goes against the HIG, as orientation should always be conserved between transitions.

So I want to be able to do the following on B :

  • Dissmiss B
  • Push C to A 's stack (so popping from C goes back to A )
  • Switch back to portrait orientation so C is displayed in portrait

If you have the Pay With Square app, you'll see that they solved this problem by fading in C (rotate the app to show the map and choose an annotation) but they didn't add it to the current stack, allowing only dismiss it.

您可以像平常一样推动视图控制器,然后在viewDidAppear中使用线程中的一些代码来旋转视图。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM