启动屏幕问题iPhone

时间:2016-01-21 10:28:19

标签: ios iphone swift

我在Xcode中使用Launch屏幕为我的应用程序执行启动画面。

启动画面上只有一个图像,背景中没有API命中 在启动屏幕上花费的时间太长,时间超过20秒且应用程序在那里崩溃,我也在设备日志上检查了它。

有时候它会崩溃,有时会运行,但总是需要很长时间 我无法从那里移动到下一个屏幕。并且它仅在iPhone 6 Plus的启动屏幕之前显示白屏(其他设备上没有白屏)。

如何解决iPhone 6 Plus的白屏问题并解决启动画面时间问题?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
    {

        // Override point for customization after application launch.
        // self.prepareForContact()
        if let a: AnyObject = (NSUserDefaults.standardUserDefaults().objectForKey("isFirstTime"))
        {
            if let a: AnyObject = (NSUserDefaults.standardUserDefaults().objectForKey("userid"))
            {
                self.createAppFromHomepage()
            }
        }
        else
        {
            self.createAppFromWelcomeScreen()
        }

        isAllImageDownloading = false
        // Save this data to hit friend service on login on every launch...
        NSUserDefaults.standardUserDefaults().setObject("1", forKey: "hitFriendService")

        let credentialsProvider = AWSCognitoCredentialsProvider(regionType: CognitoRegionType, identityPoolId: CognitoIdentityPoolID)
        let configuration = AWSServiceConfiguration(region: DefaultServiceRegionType, credentialsProvider: credentialsProvider)
        AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration

        //print(credentialsProvider.secretKey)

        if let event_id: AnyObject = NSUserDefaults.standardUserDefaults().objectForKey("eventId")
        {
            self.getEventDescription()
            self.uploadEventRemainingImages()
        }


        let session1 = AVAudioSession.sharedInstance()
        session1.setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: AVAudioSessionCategoryOptions.MixWithOthers|AVAudioSessionCategoryOptions.DefaultToSpeaker|AVAudioSessionCategoryOptions.AllowBluetooth, error: nil)
        session1.setActive(true, error: nil)
        UIApplication.sharedApplication().beginReceivingRemoteControlEvents()


        let nsDocumentDirectory = NSSearchPathDirectory.DocumentDirectory
        let nsUserDomainMask    = NSSearchPathDomainMask.UserDomainMask
        if let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
        {
        if let dirPath = paths[0] as? String
        {
            self.excludeFromBackupToICloud(dirPath)
        }
        }

        if application.respondsToSelector("registerUserNotificationSettings:") {

            let types:UIUserNotificationType = (.Alert | .Badge | .Sound)
            let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)

            application.registerUserNotificationSettings(settings)
            application.registerForRemoteNotifications()
        }
        else
        {
            // Register for Push Notifications before iOS 8
           // application.registerForRemoteNotificationTypes(.Alert | .Badge | .Sound)
        }

         if let isFirstTime: AnyObject = NSUserDefaults.standardUserDefaults().objectForKey("isFirstTime")
         {
         }
        else
         {
            UIApplication.sharedApplication().applicationIconBadgeNumber = 0
          //  NSUserDefaults.standardUserDefaults().setObject("1", forKey: "isFirstTime")
         }
        return true
    }

1 个答案:

答案 0 :(得分:0)

你被看门狗杀死了。你的应用程序不会因为说而崩溃。

<强>究

乐器下配置您的应用:您将立即看到拍摄的内容。

<强>修正

允许didFinishLaunchingWithOptions立即返回。在一个单独的方法中排除所有艰苦的工作,您可以这样调用:

<强>夫特

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.performSelectorOnMainThread("didFinishLaunching", withObject: nil, waitUntilDone: false)
    return true
}

并在返回(下一个事件循环)后做了很多努力

func didFinishLaunching() {
    // time consuming work goes here
}

<强>目标C

[self performSelectorOnMainThread:@selector(didFinishLaunching)
                       withObject:nil
                    waitUntilDone:NO];

- (void) didFinishLaunching {
    // time consuming work goes here
}