设置横屏没有生效:[[UIDevice currentDevic
2019-01-23 本文已影响10人
JACK_岩
设置横屏(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;
}