As the title says. My UIViewController will not rotate no matter what. When it loads shouldAutorotateToInterfaceOrientation is being called but after that it doesnt.
UPDATE 1:
It’s a really really wierd problem. At least for me. And i ll try to explain everything.
It’s a navigation based app. Every controller has
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}
Xcontroller is a child of Acontroller and it doesn’t auto rotate. If Xcontroller become a child of Bcontroller then it will autorotate. So something is wrong with Acontroller. But Acontroller is identical (except its data) to Bcontroller.
Whats Wrong?
UPDATE 2:
I decided to recreate Acontroller. And it worked.I believe I was missing something stupid.
I am not sure whether it’s the same reason as your case. But I experienced the same thing. the
shouldAutorotateToInterfaceOrientationwas only called once in the beginning.After some serious debugging by taking code apart, I found that the reason is in my overridden init method.
I had this before:
And then I changed to this
Note: the only difference is I added
[super init]to call the parent init.After this change, the rotation works well and the shouldAutorotateToInterfaceOrientation is being called everytime I rotate the screen.
Hope this help.