Reputation: 42277
I have a LaunchScreen.storyboard that I'd like to reuse.
The problem I'm having is that viewDidLoad gets triggered too quickly. There's some initial processing being done in the background when the app starts up. Because the processing is going on in the background, there's a short gap because viewDidLoad fires off after just a second, but here's about 5 seconds before the background processing is done.
I'd like to load and display the LaunchScreen.storyboard at the beginning of viewDidLoad to extend it until the background stuff is done.
I'm trying to adapt this:
let storyboard = UIStoryboard(name: "LaunchScreen", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
However, its erroring out with:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'someViewController''
Clearly, one of the problems is 'someViewController'. I don't know if the LaunchScreen storyboard has a view controller, so that's where I'm stuck.
Definitely would appreciate any pointers.
Upvotes: 3
Views: 1056
Reputation: 8006
someViewController
should be actually a name set in Interface Builder. I'm afraid that there is no easy way (if any) to reuse a LaunchScreen.storyboard
(which actually is a xib
) - if you look at it in Interface Builder, there is no View Controller
there, only a view
- the rest is done under the hood.
Now to address your issue - you can do two things :
Add a "splash screen" view controller identical to your launch screen and dismiss it only after the app has loaded data. I'm not certain, but bear in mind that this may be a reson for disapproval during review by Apple, as you are intentionally prolonging the startup of your application.
This way is better in my opinion - Indicate to the user that your app is still loading some data, and refresh your views after it finished.
Upvotes: 2