Add info for use with storyboards
blwinters opened this issue · 5 comments
For a while I couldn't figure out why the LTHPasscodeViewController was showing up inconsistently. I thought my problem was related to #145. Then I changed my storyboard initialization process (in order to immediately show a login screen over my UITabBarViewController after launch), and now it's working beautifully. I recommend that you add some info to the How To Use section of the README for use with storyboards.
For me, I had to remove the storyboard name from Target > General > Deployment Info > Main Interface.

Then in application(didFinishLaunchingWithOptions:)
window = UIWindow(frame: UIScreen.main.bounds)
if let window = window { //setup rootViewController manually instead of using storyboard so that PasscodeViewController can be shown immediately
window.backgroundColor = UIColor.white
window.rootViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateInitialViewController()
window.makeKeyAndVisible()
}
//setup passcode appearance...
if LTHPasscodeViewController.doesPasscodeExist() && LTHPasscodeViewController.didPasscodeTimerEnd() {
LTHPasscodeViewController.sharedUser().showLockScreen(withAnimation: false, withLogout: false, andLogoutTitle: nil)
}
Hey Ben,
Thank you for your input and help, but, sadly, I don't use Storyboards, so the support for them is ... unofficial; it was added by a user. That means I have no idea if your scenario is a standard one, or a special case, because if it is, it can't really be added to the README. Is removing the Main something usual? When using Storyboards, isn't that the entry point of the app?
I would definitely like to add something to the README, since it would help developers, but it would have to be something that generally applies to (almost) everyone.
I've only been using this approach for a couple weeks, but it works fine and I originally saw it in a project by another developer. Here is a StackOverflow link about the topic.
My understanding is that programmatically setting window.rootViewController = UIStoryboard(...) does the exact same thing as entering the storyboard name in the Deployment Info. However, doing it programmatically gives us more control over the order of which view controller is shown first. It doesn't affect the functionality of storyboards.
Hey Ben,
I see, and it makes total sense. But the problem is that if this isn't a familiar / spread approach, it would be kinda wrong to recommend it in the README. I will leave the issue open for a while, add some labels, and maybe we'll get some more feedback on this.
Sure, that sounds good. I'd also like to know if the community has more information on the implications of this.
Almost a year has passed, no outside input was received, and I still don't work with Storyboards :)
I added a short description pointing to this issue, maybe others will find the info useful, and I can also close the issue.
Thank you!