UIInterfaceOrentation on iPad
I have an app that is a game, and it does not look or work right in Landscape.
Right now My code is:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.开发者_StackOverflow中文版
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
And that allows it only to run in portrait (home button on bottom) and I want it to run in both Portrait's (Home button on bottom OR top) so apple accepts it.
I have tried:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
and it didnt work... Can someone give me the Code to make it so it runs in both portrait modes.
You can only return once, so the second return statement is never evaluated. Make it a boolean OR:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) || (interfaceOrientation == UIInterfaceOrientationPortrait);
}
There are also macros for portrait and landscape, but this should work just fine.
精彩评论