Xcode - 强制启动屏幕加载横向

时间:2015-09-04 02:44:12

标签: ios xcode

启动屏幕当前默认为设备当前方向。 我试图以编程方式设置它,但它仍然无法正常工作。

[0] = [*]There is my first text
[1] = 
[2] = There is my second text, 1
[3] = There is my second text, 2

enter image description here enter image description here

2 个答案:

答案 0 :(得分:0)

您可以在目标的常规设置中设置Device Orientation

enter image description here

参考:http://www.raywenderlich.com/63229/make-game-like-mega-jump-spritekit-part-12

答案 1 :(得分:0)

最后,我想出了一个解决方案。在应用程序运行之前生成启动屏幕,因此这是一个技巧。

在项目的常规设置中,仅选中左右横向,因此它只会生成横向闪屏图像。并按照以下方式调整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];
}

@end