Xcode 7 GM(iOS9) 不支持启动画面动画。应用程序因错误而崩溃

Splash screen animation is not supporting with Xcode 7 GM(iOS9). App crashes with an error

在我的应用程序中,我使用以下代码来显示动画启动画面。应用程序在 Xcode-6.4(iOS 8) 中运行良好,但进入 Xcode-7GM 版本(iOS9) 应用程序崩溃并出现错误。

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT];
    // Build array of images, cycling through image names
    for (int i = 1; i <= IMAGE_COUNT; i++)
     [imageArray addObject:[UIImage imageNamed:
                               [NSString stringWithFormat:@"image__%d.png",i]]];
    animationImageView  = [[UIImageView alloc]  initWithFrame:self.window.bounds];
    animationImageView  .animationImages=[NSArray arrayWithArray:imageArray];
    // One cycle through all the images takes 3.5 seconds
    animationImageView .animationDuration = 3.5;
    // Repeat forever
    animationImageView  .animationRepeatCount = 0;
    // Add subview and make window visible
    [window addSubview:animationImageView  ];
    [window makeKeyAndVisible];
    // Start it up animations
    [animationImageView   startAnimating];
    // Wait 3.5 seconds, then stop animation
   [self performSelector:@selector(stopAnimation) withObject:nil afterDelay:3.5];`

这是我在使用 Xcode-7GM:

时收到的错误消息

Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294

听起来你在尝试建立一些网络。在iOS 9,默认情况下,所有网络通信都必须是安全的。如果您尝试执行 http: 请求,它将失败;您必须使用 https:(除非您在 Info.plist 中关闭此功能)。

我有同样的问题,已通过删除 [window makeKeyAndVisible];.

解决

需要在 didFinishLaunchingWithOptions: 中将自己 window 设置为根视图控制器::
[self.window setRootViewController:navController];

对于像 jonmo 这样的我来说,这个错误是在退出 didFinishLaunchingWithOptions 之前没有定义 rootViewController 的结果。

这样做为我解决了这个问题。

在Xcode7之前只是警告,现在好像是硬停


    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

改为


    [window setFrame:[[UIScreen mainScreen] bounds]];

在我的例子中,此错误消息的解决方案是更新一个包含的名为 Loopback 的 CocoaPods 依赖项(我相信它会向应用程序添加一个额外的 UIWindow。)

我有同样的问题,已通过替换 Appdelegate.m

中的以下代码行解决
[window addSubview:viewController.view];

[window setRootViewController:viewController];