不知道如何在iOS 8中上下颠倒方向工作?



我在iPhone 6的AppDelegate.m中添加了UIScreen边界代码,现在iPhone 6的设备方向不适用于Portrait/Upside Down。倒置是模拟器和设备中不起作用的东西。

AppDelegate.m 中的代码

 CGSize iosScreenSize = [[UIScreen mainScreen] bounds].size;
    if (iosScreenSize.height == 667) {
        UIStoryboard *iPhone6 = [UIStoryboard storyboardWithName:@"iPhone6" bundle:nil];
        UIViewController *initialViewController =[iPhone6 instantiateInitialViewController];
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
        self.window.rootViewController = initialViewController;
        [self.window makeKeyAndVisible];
    }

当我包含上述代码时,iPhone 6的模拟器和设备无法检测到倒置方向。我还使用了nativeBounds和screenBounds,对于倒置方向都不起作用。

我的设备定向代码。。。

 -(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
 }

我不知道该怎么做才能获得AppDelegate代码来检测iPhone 6的上下方向。

好吧,终于找到了这个。

然后意识到有人在这里发布了答案:在Swift iOS 中设置设备方向

往下看DaRk-_-D0G的答案。

我不得不将我的选项卡栏控制器子类化为来覆盖该方法。非常讨厌.

最新更新