gpt4 book ai didi

iphone - 如何仅在 iPhone 6+ 上旋转 iOS 应用程序

转载 作者:行者123 更新时间:2023-12-03 20:40:13 25 4
gpt4 key购买 nike

我的应用程序在 iPhone 上处于纵向模式。我还有iPad版本,可以旋转。现在,有了新的 iPhone 6+,我想轮换我的应用程序。我发现了有关此问题的任何问题/解决方案。

我能想到的有两种方法

a) 更好的解决方案(恕我直言)- 仅为特定设备启用旋转。可以在不编辑项目设置中某处代码的情况下完成吗?

b) 在 iPhone6+ 上使用 iPad 版本的 Storyboard,而不是经典 iPhone 版本的 Storybaod。它可以在 XCode Storyboard或项目设置中完成吗?还是我必须在我的代码中执行此操作?我没有找到其他解决方案,可以根据设备识别在代码中加载某些 Storyboard。

最佳答案

这里有一个简单的方法来实现这一点。只需将以下内容添加到您的 UIApplicationDelegate 中:

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
static UIInterfaceOrientationMask rv = 0;
if( rv == 0 ) {
if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) {
CGSize s = window.bounds.size;
if( MAX( s.width, s.height ) >= 700.0f ) {
rv = UIInterfaceOrientationMaskAllButUpsideDown;
} else {
rv = UIInterfaceOrientationMaskPortrait;
}
} else {
rv = UIInterfaceOrientationMaskAll;
}
}
return rv;
}

关于iphone - 如何仅在 iPhone 6+ 上旋转 iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26328502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com