如何改善iOS中的应用启动时间?

时间:2018-06-07 18:15:00

标签: ios xcode user-interface launch

我的应用在发布时非常慢。它显示了很长一段时间的启动图像。 (约25秒)

将此日志记录在我的Xcode调试器区域中,如下所示:

    Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 2911, TID: 1614792, Thread name: ComScore-Analytics, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication keyWindow]
PID: 2911, TID: 1614792, Thread name: ComScore-Analytics, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIWindow rootViewController]
PID: 2911, TID: 1614792, Thread name: ComScore-Analytics, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
PID: 2911, TID: 1614792, Thread name: ComScore-Analytics, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView bounds]
PID: 2911, TID: 1614792, Thread name: ComScore-Analytics, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:

(Xcode 9,iOS 9,10,11,Objective-C的app支持)

我在AppDelegate.m中的代码看起来像这样,(在didFinishLaunchingWithOptions

self.shareWindow = [[DFWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.shareWindow.backgroundColor         = [UIColor clearColor];
    MySharingNavController *navController = [[MySharingNavController alloc] init];
    self.shareWindow.rootViewController      = navController;
    self.shareWindow.windowLevel             = 1.0f;

    // Video Window
    self.videoWindow = [[DFWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.videoWindow.backgroundColor            = [UIColor clearColor];
    MyVideoNavControllerViewController* videoRootViewController   = [[MyVideoNavControllerViewController alloc] init];
    self.videoWindow.rootViewController         = videoRootViewController;
    self.videoWindow.windowLevel                = 2.0f;

    [[DFAxisVideoPlaybackMediator sharedVideoPlaybackMediator] setRootViewController:videoRootViewController];

    self.rootViewController = [[MyRootViewController alloc] init];

    // Main Window
    self.window = [[MyWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [self.window makeKeyAndVisible];
    self.window.rootViewController = self.rootViewController;

1 个答案:

答案 0 :(得分:0)

我已经通过添加一些代码更新了这个问题,用于在didFinishLaunchingWithOptions中设置根视图控制器,AppDelegate.m