Mpampinos Holmens
Mpampinos Holmens

Reputation: 1937

Supporting orientations IOS

Hello i want to support portrait, home button up and down in my application how can i do that?

i go to my project settings check those two enter image description here

and i add the code below

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation); 
}

I also tried

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

but none seems to work

any help

Upvotes: 0

Views: 209

Answers (1)

Nitin Alabur
Nitin Alabur

Reputation: 5812

Try this

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{  
    if((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
        return YES;
   }
   return NO;
}

If it still doesn't work, you can try this (just for the sake of testing)

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{  
    return YES;
} 

if this doesn't work, either you are not messing with the right view controller, or the parent/root view controller has rotation disabled (returning NO in shouldAutoRotate method of the rootVC)

Upvotes: 2

Related Questions