Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App only rotates in iOS 6 and not in iOS 5

I have made an app targeted for iOS 5 and iOS 6, and for some reason it only rotates when using it on devices with iOS 6, wether on an iPhone or an iPad, and doesn't rotate on devices using iOS 5. My app is universal. Please help me resolve this problem! Thanks

like image 680
Ivan Diaz Avatar asked Dec 15 '22 18:12

Ivan Diaz


2 Answers

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}

overide these two methods in your all uiviewcontroller subclasses ...... this will work for ios 6 and earlier

like image 107
Shaik Riyaz Avatar answered Dec 28 '22 08:12

Shaik Riyaz


iOS 5 and iOS 6 call different orientation and rotation delegates. In iOS 5, implement:

shouldAutorotateToInterfaceOrientation:, which is deprecated in iOS 6.

So, in iOS 6, make sure you set a root view controller, and implement:

shouldAutorotate:, supportedInterfaceOrientations and supportedInterfaceOrientationsForWindow:

like image 36
hotpaw2 Avatar answered Dec 28 '22 06:12

hotpaw2