I have been scouring the internet for a solution to this but am finding nothing. I am trying to make my iOS 5 app iOS 6 compatible. I cannot get the orientation stuff to work right. I am unable to detect when a rotation is about to happen. Here is the code I am trying:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
// pre-iOS 6 support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
The new supportedInterfaceOrientation: method gets called just fine. The shouldAutorotate method, however, will not fire. I need to do some image swapping on rotate, but I can't get any indication that a rotation is about to occur.
Thanks in advance.
See if you are getting the following error when your App starts.
If so the way to fix it is by making the following change in the
AppDelegate.m
file (although there seem to be a number of answers how to fix this):After this
shouldAutoRotate
should be correctly called.This is how I would do it
if you want to check which is current orientation then add this line to your viewconrtoller.m file
then where you want to check orientation ,write condition like below