-
Notifications
You must be signed in to change notification settings - Fork 268
Storyboards
Typhoon ensures that all storyboards used in the application are instances of TyphoonStoryboard
under the hood. You don't have to worry about it - just work with UIStoryboard
as you would normally do, with the added benefit that dependencies will be injected according to the definitions in your TyphoonAssembly class(es).
This approach also works with the new iOS feature - Storyboard References.
The TyphoonComponentFactory will be retained by the storyboard, and so persists throughout the life-cycle of your application.
By default Typhoon will inject by matching the type of the UIViewController to a component in the assembly. Optionally, you can specify which definition should be used for each viewController using the 'typhoonKey' runtime attribute. Example:
If you wish to create additional storyboards programmatically, as some people do, for example, do provide one storyboard per use-case:
On the fly:
UIStoryboard *board = [UIStoryboard storyboardWithName:@"AStoryBoardName"
bundle:[NSBundle mainBundle]];
In an assembly:
- (UIStoryboard *)storyboard
{
return [TyphoonDefinition withClass:[UIStoryboard class] configuration:^(TyphoonDefinition *definition) {
[definition useInitializer:@selector(storyboardWithName:factory:bundle:)
parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:@"StoryboardName"];
[initializer injectParameterWith:[NSBundle mainBundle]];
}];
}];
}
If you don't want a specific storyboard to be powered by Typhoon - use a plist integration. Add a special key TyphoonCleanStoryboards
in your Info.plist file and list all the storyboards that don't need the activation.
See also: Storyboards work well in conjunction with Autowiring
Something still not clear? How about posting a question on StackOverflow.
Get started in two minutes.
Get familiar with Typhoon.
- Types of Injections
- What can be Injected
- Auto-injection (Objective-C)
- Scopes
- Storyboards
- TyphoonLoadedView
- Activating Assemblies
Become a Typhoon expert.
For contributors or curious folks.