问题
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