美文网首页
设置横屏没有生效:[[UIDevice currentDevic

设置横屏没有生效:[[UIDevice currentDevic

作者: JACK_岩 | 来源:发表于2019-01-23 16:02 被阅读10次

    设置横屏(oc)代码:
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];

    问题:横屏不生效!!!
    原因:General中设置了竖屏模式,Device Orientation:Portrait
    解决方法:需要在appdelegate设置
    oc:
    -- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    swift:
    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.allButUpsideDown;
    }

    相关文章

      网友评论

          本文标题:设置横屏没有生效:[[UIDevice currentDevic

          本文链接:https://www.haomeiwen.com/subject/mvxsjqtx.html