Forcing UIInterfaceOrientation changes on iPhone

前端 未结 1 1596
北海茫月
北海茫月 2020-12-06 18:18

I\'m strugging with getting an iPhone application which requires just about every push or pop in the Nav Controller Stack to change orientation.

Basically the first

相关标签:
1条回答
  • 2020-12-06 18:59

    You shouldn't use [UIViewController shouldAutorotateToInterfaceOrientation:] to trigger an orientation change; it's only there to let the system know if automatic rotations are allowed. You should still update it to specify the orientation that's allowed though.

    If you want to change the orientation when a particular view is showing, you should call [UIApplication setStatusBarOrientation:animated:] inside your [UIViewController viewWillAppear:] override method for each of the view controllers that force a particular orientation. That will cause a change when a view is being pushed onto the stack and when it's being popped off it. Make sure you call super in your override method.

    This is also the right place to change how the status bar is displayed, if that's something you're doing.

    0 讨论(0)
提交回复
热议问题