0

I have 3 vcs (say VC_A, VC_B, VC_C, all embedded in a navigation controller which has a subclassed uinavigationcontroller class (say MyNavClass). In MyNavClass I have overridden supportedInterfaceOrientations().

In this method I have a statement like this:

NSLog(self.topViewController.restorationIdentifier!)

For whatever reason, when I navigate through the view chain, only VC_A is logged to console, but not VC_B and VC_C. Any ideas why?

VC_A has a navigation bar item that leads to VC_B. VC_B has a collection view, and on selecting an item in this collection view, VC_C is shown. And you can navigate all the way back to VC_A using the nav bar back button.

I also tried various combinations as follows but none works:

NSLog(self.visibleViewController!.restorationIdentifier!)
NSLog(self.navigationController?.viewControllers.last.name)

EDIT: I just realized the supportedInterfaceOrientations is not getting called at all when VC_B and VC_C are pushed onto the navigation controller! Why is this happening. How to solve this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
DS.
  • 2,846
  • 4
  • 30
  • 35
  • Even on rotation its not getting called? – Christeena John Jan 07 '15 at 07:00
  • Maybe I'm approaching this wrong. My initial requirement is still the same. Any ideas how to achieve this? Basically - one navigation controller - 3 views - last view should rotate but the other two should not. I am using the approach as mentioned above. – DS. Jan 08 '15 at 03:02
  • In MyNavClass add -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } then implement supportedInterfaceOrientations in your controllers. – Christeena John Jan 08 '15 at 05:41
  • Thanks Christeena. I crafted a working solution with help from this thread: http://stackoverflow.com/questions/12630359/ios-6-how-do-i-restrict-some-views-to-portrait-and-allow-others-to-rotate – DS. Jan 08 '15 at 05:42

0 Answers0