Reputation: 564
the below method is not called when i rotate my device with Autolayout ON in IB.
willRotateToInterfaceOrientation:duration:
Firstly does the above methods don't wok with autolayout? the method gets called with Autolayout turned off. I am trying to change the background Image of my view on rotation, Not sure how to achieve that with autolayout constaints ON?
I also tried to use procedure by Moin but I have a huge view hierarchy and the methods are called from superview onwards, and and i have lot of other code in other methods like. So it didn't help
didRotateFromInterfaceOrientation
Upvotes: 2
Views: 884
Reputation: 564
The -willRotateToInterfaceOrientation:duration:
gets called on the root viewcontroller and all its child viewcontrollers and works with autolayout. If you want these methods to get called on a particular viewcontroller, It must be child viewcontroller of the root viewcontroller.
It took me a while to figure out that the hierarchy from the root to the last viewcontroller was breaking at some point. I just had to add it back as the child view controller.
Upvotes: 1
Reputation: 48514
The short answer:
-willRotateToInterfaceOrientation:duration:
works with AutoLayout.
The long answer: Assuming you are using NIB, so many compounding issues can go wrong ; I have compiled this checklist:
plist
as recommended by @NateFlink at Handling autorotation for one view controller in iOS7-supportedInterfaceOrientations
with incorrect values? See recommended response by @AndrewHershberger at preferredInterfaceOrientationForPresentation must return a supported interface orientation (iOS 6)Upvotes: 1