GithubHelp home page GithubHelp logo

azu / roletabbarcontroller Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 192 KB

UITabBarController patterns library - similar to <UITableViewDataSource> patterns.

License: MIT License

Objective-C 94.24% Ruby 5.76%

roletabbarcontroller's Introduction

RoleTabBarController

CI Status Version License Platform

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

  1. You create Subclass of RoleTabBarController and adopt <RoleTabBarDataSource> protocol on the subclass(AppTabBarController)
  2. You should implement <RoleTabBarDataSource> protocol
  3. 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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

roletabbarcontroller's People

Contributors

azu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.