While using Typhoon I came across this issue, but first some background.
- I'm using a storyboard.
- The storyboard starts in a home screen, then flows to login, then to the main screen (UITabBarController). I use navigation controller as root controller.
- If the user is already logged in I want to show the main screen without showing the home or login screens. This could be done in the home screen
viewDidLoad
(other suggestions welcome).
The few things i've tried are:
Using a segue from the home to the tabController but the home screen can be seen and the transition is animated (don't want this).
Instantiating the tab controller (as below) from the storyboard but the dependencies are not injected. I understand that this is because the Typhoon storyboard is not used.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *vc1 = [storyboard instantiateViewControllerWithIdentifier:@"MyAuth"];
I also tried using factory with Typhoon for the storyboard.
public dynamic func storyboard() -> AnyObject { return TyphoonDefinition.withClass(TyphoonStoryboard.self){ (definition) in definition.useInitializer("storyboardWithName:factory:bundle:"){ (initializer) in initializer.injectParameterWith("Main") initializer.injectParameterWith(self) initializer.injectParameterWith( NSBundle.mainBundle() ) } definition.scope = TyphoonScope.Singleton; //Let's make this a singleton } } ///Injection for tabbar controller public dynamic func tabBarViewController() -> AnyObject { return TyphoonDefinition.withClass(TabBarViewController.self){ (definition) in } }
On the viewDidLoad
I push the tabBarViewController (using the injected assembly) to the navigation controller but it doesn't have the tabs as specified on the storyboard.
func viewDidLoad() {
super.viewDidLoad()
if(userLoggedIn){
self.navigationController?.pushViewController(self.injectedAssembly.storyboard().tabBarController(), animated: false)
}
}
Thanks,