Simple problem, need help!

Discussion in 'iPhone/iPad Programming' started by Sweetooth44, Sep 18, 2012.

  1. macrumors newbie

    Joined:
    Sep 18, 2012
    #1
    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:
    Code:
    -(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?
     
  2. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Can't you change that to
    Code:
    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
    Code:
    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.
     
  3. thread starter macrumors newbie

    Joined:
    Sep 18, 2012
    #3
    I've got everything working fine except on the iPhone it refuses to rotate upside down.
     
  4. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    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? :)
     
  5. thread starter macrumors newbie

    Joined:
    Sep 18, 2012
    #5
    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:
     
  6. macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #6
    Post your updated shouldAutoRotate method, as well as the values in the UISupportedInterfaceOrientations entry in your app's info.plist.
     

Share This Page