【问题标题】:How to set different orientation to iPhone and iPad [duplicate]如何为 iPhone 和 iPad 设置不同的方向 [重复]
【发布时间】:2012-04-04 18:09:34
【问题描述】:

可能重复:
Best way to programmatically detect iPad/iPhone hardware

例如,我希望我的视图仅在 iPhone 上为纵向,在 iPad 上为横向。

在这种情况下如何检测我是在 iPhone 还是 iPad 上运行?

【问题讨论】:

    标签: iphone objective-c ipad orientation


    【解决方案1】:

    写在你的UIViewController:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
            return UIInterfaceOrientationIsPortrait(interfaceOrientation);
        else
            return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    

    【讨论】:

    • 嗯,我以前见过这个 userInterfaceIdiom。只是没想到会是这样。太棒了,谢谢
    猜你喜欢
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多