How to assign class to the Splash screen in Swift?

余生颓废 提交于 2019-12-09 03:11:12

问题


I m trying to change the class for call the web service from my splash screen class but it fire the error message.

Error is:

splash screen has not allowed custom class


回答1:


Your launch storyboard is shown before your app has begun executing, so, as the error says it can't execute code.

You can duplicate the scene from your launch storyboard as the initial view controller of your main storyboard, and in this storyboard you can use a custom UIViewController subclass and call your web service. Once the call is complete you can perform a segue to your required scene.




回答2:


There is no way to add behavior to Launch screens.

You should create another view to add behavior.

For example, this animation behavior is added by using another storybaord:
https://github.com/okmr-d/App-Launching-like-Twitter

After launch screen ended, func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool is called, so you can add your own behavior like this:
https://github.com/okmr-d/App-Launching-like-Twitter/blob/6642733d4d7948fd706950665b8ecc97018b105b/App%20Launching%20like%20Twitter/AppDelegate.swift#L20-L86




回答3:


You cannot because there is no class assigned for splash screen(Launch screen) in XCode.



来源:https://stackoverflow.com/questions/39976642/how-to-assign-class-to-the-splash-screen-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!