在ios,swift的首次发布中,视图完全是黑色的几秒钟

时间:2017-01-29 05:53:05

标签: ios swift uiimage splash-screen branch.io

  1. 我被要求在应用启动时显示两个Splash Screens。一 对于特定的一组客户和另一组客户 顾客。据我所知, Apple 不允许显示两个闪光 屏幕,因为它已经签署到Bundle。所以我决定 使用UIImageView并按照checking群组更改图片。
  2. 要检查我使用deep links提供的Branch.io组。当有人来自我们创建的referral链接时,会显示一个image,如果有人来自正常方式,我们会将另一个image显示为launch图片,而不是启动画面。它运作正常。
  3. 但是第一次发布时,它显示Black Screen五到六秒(相当长的时间)并显示图像。
  4. 如果不是第一次,它可以正常工作。(黑屏1到2秒。)
  5. 以下是我用来检查条件并在另一个image中显示viewController的方法。

    AppDelegate中,在我使用didFinishLaunchWithOption检查的branch方法中,如下所示。

    let branch:Branch = Branch.getInstance() // branch.setDebug()

        branch.initSessionWithLaunchOptions(launchOptions) { (params, error) in
            if error == nil {
    
                let clickedBranchlink : Bool = params["+clicked_branch_link"] as! Bool
                let isfirstSession : Bool = params["+is_first_session"] as! Bool
    
    
                if clickedBranchlink == true {
                     let theReferrer : String = params["referrer"] as! String
                    if theReferrer == "groupA" {
    
    
                   // in here I checked the group and set userdefault values and navigate to the view which the image view has and show the image according to this condition.
                    }
    
    }
    }
    
      

    注意:是否有办法增加此过程并减少   黑屏。我是否在主线程中执行此操作。因为第一次   避免通过branch.initSessionWithLaunchOptions然后   它经历了它。希望你的帮助。

1 个答案:

答案 0 :(得分:0)

每次启动应用程序并且应用程序不在后台时,都会调用此initSessionWithLaunchOptions。鉴于您的观察结果仅在第一次安装应用程序时出现问题,我的预感是您在调用Branch initSessionWithLaunchOptions函数之前在didFinishLaunchingWithOptions中运行代码。

分支初始化过程涉及发送网络请求然后等待响应,因此这总是需要一些时间 - 但安装与其他任何打开所花费的时间没有区别。在执行didFinishLaunchtingWithOptions中的任何其他代码之前,尽快启动此异步分支初始化,并且您应该能够缩短启动页面显示之前的时间。这应该消除显示您认为可能与Branch相关的启动图像所花费的时间的任何变化。