Execute Code in Launch Screen UPDATED

后端 未结 3 1123
一整个雨季
一整个雨季 2021-01-22 10:05

Execute Code in Launch Screen ORIGINAL

Now that the default LaunchScreen file in Xcode projects have been changed from .xib to .storyboar

相关标签:
3条回答
  • 2021-01-22 10:32

    It is not possible to write any custom class/code for the launchscreen xib/storyboard files. We can only design using resource files.

    0 讨论(0)
  • 2021-01-22 10:32

    Yes, its possible to write ViewController for the launch screen,

    1) Create viewController file, create Xib for the same.

    2) In the RootViewController's (say HomeViewController or SignInViewController) ViewDidLoad(),

    2a) Create object of SplashViewController.

    2b) Add view of splashViewController to your HomeViewController.

    let objSplashVC = yourCode to create object of SplashVC
    self.view.addSubView(objSplashVC.view);
    

    c) After 2 or 3 seconds or once your retrieve data on Web-Service call, you can remove that view, by calling hide() method of SplashViewController

    hide(){
           self.view.removeFromSuperView();
       }
    

    Note : You have to add background image on SplashViewController as same as launchImage. So transitions will go smoothly.

    0 讨论(0)
  • 2021-01-22 10:37

    Completely Agree with Arun Ammannaya. I ran a test to verify it and here is the result.

    0 讨论(0)
提交回复
热议问题