【问题标题】:iphone how to change landscape to portrait?iphone如何将横向改为纵向?
【发布时间】:2012-11-13 06:56:44
【问题描述】:

我在 iPhone 上开发了一个简单的游戏。整个游戏为横向模式,但计分板页面仅支持纵向模式。我已经检查了here的问题,我只发现将纵向模式转换为横向模式,但我需要相反的答案。谁能帮帮我?

【问题讨论】:

标签: iphone


【解决方案1】:

这很简单。首先,确保目标摘要中同时支持纵向和横向。那么:

在横向视图控制器中,添加以下内容:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

并在纵向 ViewController 中添加:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

【讨论】:

    【解决方案2】:

    我在 AppDelegate 中使用了这两个调用。仅在横向获取游戏中心(记分板)。

    // Supported orientations: Landscape. Customize it for your own needs
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    
    
    
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
    - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
    {
        return UIInterfaceOrientationMaskAllButUpsideDown; //Getting error here? then update ur xcode to 4.5+
    }
    #endif
    

    Xcode 设置:标记横向。

    【讨论】:

    • shouldAutorotateToInterfaceOrientation 自 iOS 6 起已弃用。
    • @WolfLink,是的,supportedInterfaceOrientationsForWindow 在我的代码中用于 ios6.. 它工作得很好:) 无论如何谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-21
    • 1970-01-01
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 2020-10-13
    • 1970-01-01
    相关资源
    最近更新 更多