PDA

View Full Version : Simple problem, need help!




Sweetooth44
Sep 18, 2012, 04:07 AM
I'm sure this isn't new, but I'm having a few small issues with getting my app to play nicely under iOS 6. I'm sure it's an easy fix; I just can't get it working properly. My app:

On iPhone *only works in portrait + portrait upside down
On iPad *works in all orientations

Here is the code I've been using:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{

UIDevice* thisDevice = [UIDevice currentDevice];

if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
return YES;
}
else
{
return (orientation != UIDeviceOrientationLandscapeLeft) &&
(orientation != UIDeviceOrientationLandscapeRight);
}
}

What should I change it to?



jnoxx
Sep 18, 2012, 04:41 AM
Can't you change that to

UIInterfaceOrientationIsPortrait(orientation);

instead of the orientation !=
Hope that helped.
What I tend to use is DeviceHW, is a tool to check if you are on iPad etc, it contains class methods, so instead of recreating the UIDevice thing, you can just go like

if ([DeviceHW isiPad]) {
Blah
} else {
Blah
}


You can also write this yourself ^_-
Or you can write a handler for the orientations, so you don't have to repeat it in each controller.

Sweetooth44
Sep 18, 2012, 05:25 AM
I've got everything working fine except on the iPhone it refuses to rotate upside down.

jnoxx
Sep 18, 2012, 08:34 AM
On your project settings, on your target, you can select what sides it should be able to rotate, also should be in your project plist. Sure it's alright there? :)

Sweetooth44
Sep 18, 2012, 08:58 AM
I've got it all set up properly there too. The iPad version is perfect, I just can't get the iPhone to go upside down :confused:

Duncan C
Sep 19, 2012, 11:35 AM
I've got it all set up properly there too. The iPad version is perfect, I just can't get the iPhone to go upside down :confused:

Post your updated shouldAutoRotate method, as well as the values in the UISupportedInterfaceOrientations entry in your app's info.plist.