首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIInterfaceOrientation Xcode

UIInterfaceOrientation Xcode
EN

Stack Overflow用户
提问于 2012-03-03 03:46:04
回答 1查看 3.8K关注 0票数 0

我希望我的应用程序支持PortraitUpSideDown定位。我已经更改了info.p列表以反映这一点,并尝试将更改作为测试在一个视图上实现

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
    return YES;

}

但这种观点没有做出回应。在应用程序响应之前,我需要在所有视图上实现这一点吗?是否有需要更改的Xib设置?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-03 03:48:50

如果您想同时支持这两种横向,请尝试以下方法:

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

或者:

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

或者看起来像你想要写的东西:

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation == UIInterfaceOrientationPortrait) {
        return YES;
    }
    if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        return YES;
    }
    return NO;
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9539425

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档