启动屏幕当前默认为设备的当前方向。我已经尝试通过编程来设置它,但它仍然不起作用。
override func viewDidLoad() {
super.viewDidLoad()
if UIDevice.currentDevice().orientation == UIDeviceOrientation.Portrait || UIDevice.currentDevice().orientation == UIDeviceOrientation.PortraitUpsideDown || UIDevice.currentDevice().orientation == UIDeviceOrientation.Unknown {
UIDevice.currentDevice().setValue(UIInterfaceOrientation.LandscapeLeft.rawValue, forKey: "orientation")
}
}


发布于 2015-09-04 10:47:03
您可以在目标的常规设置中设置Device Orientation。

参考:http://www.raywenderlich.com/63229/make-game-like-mega-jump-spritekit-part-12
发布于 2017-09-19 15:42:22
最后,我想出了一个解决方案。启动屏幕是在应用程序运行之前生成的,所以这里有一个技巧。
在你的项目的常规设置中,只勾选左右景观,这样它就只会生成景观开机画面。并按如下方式混合NSBundle的infoDictionary方法:
@interface NSBundle (Hook)
@end
@implementation NSBundle (Hook)
+ (void)load {
[NSBundle jr_swizzleMethod:@selector(infoDictionary)
withMethod:@selector(hook_infoDictionary)
error:NULL];
}
- (NSDictionary<NSString *, id> *)hook_infoDictionary
{
NSMutableDictionary <NSString *, id> *dict = [[self hook_infoDictionary] mutableCopy];
dict[@"UISupportedInterfaceOrientations"] = @[@"UIInterfaceOrientationPortrait",
@"UIInterfaceOrientationLandscapeLeft",
@"UIInterfaceOrientationLandscapeRight",
@"UIInterfaceOrientationPortraitUpsideDown",
];
return [dict copy];
}
@endhttps://stackoverflow.com/questions/32389284
复制相似问题