开发者

iPhone How to set up a view Upside Down mode

开发者 https://www.devze.com 2023-03-05 21:37 出处:网络
We developed an app in Portrait mode, without acelerometer support. We need, for usability, to turn 180º de app, so we need the app on Upside Down mode. We check in xib properties, if we found somet

We developed an app in Portrait mode, without acelerometer support.

We need, for usability, to turn 180º de app, so we need the app on Upside Down mode. We check in xib properties, if we found something magical to achive that...no way

any, clue? any he开发者_如何学编程lp?

thanks in adavance


As stated by Steven Kramer, define this in your view controller :

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
    return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    return YES to allow it or NO to forbid it
return NO; // Unknown value
}

If you only want to accept landscape mode for example, use

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

For portrait only, use return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);


Your view controller needs to override -[UIViewController (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation] and return YES for upside down portrait orientation.

Can't be done in IB.

0

精彩评论

暂无评论...
验证码 换一张
取 消