RoleTabBarController
RoleTabBarController provide Implementing UITabBarController pattern.
- Similar to
<UITableViewDataSource>
patterns.
RoleTabBarController
is not special, but it's just another pattern.
Installation
pod 'RoleTabBarController'
Example
See Example/
or
pod try RoleTabBarController
RoleTabBarDataSource
You should implement <RoleTabBarDataSource>
protocol on subclass of RoleTabBarController
@protocol RoleTabBarDataSource <NSObject>
/**
* Life Cycle
*
* numberOfRoleTabBarController
* -> ViewController - viewControllerAtIndex
* -> TabBarItem - tabBarItemObjectAtIndex
* -> TabBarItem - willShowTabBar
*/
- (NSUInteger)numberOfRoleTabBarController:(RoleTabBarController *) tabBarController;
- (UIViewController *)roleTabBarController:(RoleTabBarController *) tabBarController viewControllerAtIndex:(NSUInteger) index;
- (RoleTabBarItemObject *)roleTabBarController:(RoleTabBarController *) tabBarController tabBarItemObjectAtIndex:(NSUInteger) index;
@optional
- (void)roleTabBarController:(RoleTabBarController *) tabBarController willShowTabBar:(UITabBarItem *) tabBarItem atIndex:(NSUInteger) index;
@end
How to use
- You create Subclass of
RoleTabBarController
and adopt<RoleTabBarDataSource>
protocol on the subclass(AppTabBarController) - You should implement
<RoleTabBarDataSource>
protocol - That's all
@interface AppTabBarController : RoleTabBarController <RoleTabBarDataSource>
@end
@interface AppTabBarController ()
@property(nonatomic, strong) AppTabBarControllerModel *model;
@end
@implementation AppTabBarController
- (AppTabBarControllerModel *)model {
if (_model == nil) {
_model = [[AppTabBarControllerModel alloc] init];
}
return _model;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSource = self;
[self reloadData];
}
#pragma mark - RoleTabBarController
- (NSUInteger)numberOfRoleTabBarController:(RoleTabBarController *) tabBarController {
return 4;
}
- (UIViewController *)roleTabBarController:(RoleTabBarController *) tabBarController viewControllerAtIndex:(NSUInteger) index {
return [self.model viewControllerAtType:(AppTabBarControllerType)index];
}
- (RoleTabBarItemObject *)roleTabBarController:(RoleTabBarController *) tabBarController tabBarItemObjectAtIndex:(NSUInteger) index {
return [self.model tabBarItemObjectAtIndex:index];
}
@end
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT