0

In trying to solve this issue of pushing/popping view controllers with different orientations, one solution seems to be two UINavigationControllers, one to handle the portrait orientations and the second to handle landscape orientations.

Assume A and B are portrait view controllers; C and D are landscape view controllers.

In other words, pushing B->C should yield landscape, C->D should also be landscape, but popping from C->B should be portrait.

UINavigationController1 is a custom UINavigationController class that always forces portrait.

UINavigationController2 is another custom class, but this one forces landscape.

A and B are embedded inside UINavigationController1.

C and D are embedded inside UINavigationController2.

When pushing from B->C, we push UINavigationController2 onto the stack of UINavigationController1.

So far in testing it seems to work, but is anyone aware of any potential gotchas? The fear is there are some lurking performance/behavioral issues that won't surface until much later.

Community
  • 1
  • 1
Crashalot
  • 33,605
  • 61
  • 269
  • 439
  • arent you can just force the vc to be support only landscape? why need to use 2x navcontroller – Tj3n Jan 05 '17 at 03:47
  • @Tj3n if you look at the linked question, the challenge is forcing the VC to only support landscape for C & D while portrait for A & B. orientations don't change upon pushing/popping. – Crashalot Jan 05 '17 at 03:55
  • You can simply use `- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator` method to detect orientation change and adjust your view accordingly right. Why are doing things like this? – KrishnaCA Jan 05 '17 at 06:19
  • @KrishnaCA that doesn't work because pushing/popping view controllers don't force an orientation change. – Crashalot Jan 05 '17 at 07:15

0 Answers0