Giter VIP home page Giter VIP logo

jdragontablemanager's Introduction

JDragonTableManager

iOS UITableView的DataSource和delegate 优化封装

##基本使用

##Controller 方法
#import "JDragonTableManager.h"
#import "UITableView+JDragonTableManager.h"
@interface UITableViewController ()

@property (weak, nonatomic) IBOutlet UITableView   *aTableView;
@property (nonatomic,strong) JDragonTableManager   *tabDelagate;
@property (nonatomic,strong) JDragonTableManager   *tabDataSource;

@end

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self setUIConfig];
}
-(void)setUIConfig
{
    self.aTableView.estimatedRowHeight = 50;
    [self.aTableView registerClass:[aTableViewCell class] forCellReuseIdentifier:@"aTableViewCell"];
    [self.aTableView registerNib:[UINib nibWithNibName:@"bTableViewCell" bundle:nil] forCellReuseIdentifier:@"bTableViewCell"];

    self.tabDelagate = [self.aTableView JDTab_DelegateWithHeaderHeight:10 footerHeight:10 selectBlock:^(NSIndexPath *indexPath) {
    NSLog(@"选中");
    }];
    // 需要实现JDTableManagerDelegate 代理在cell里面
    self.tabDataSource = [self.aTableView JDTab_DataSourceWithSource:@[@"111",@"222"] withTabType:NumberOfRowsInSectionCount withVC:self isSection:true reuseIdentifier:@"aTableViewCell"];
    /*
    //第二种方式,可以不带原数据
    self.tabDataSource = [self.aTableView JDTab_DataSourceWithTabType:NumberOfRowsInSectionCount withVC:self isSection:true reuseIdentifier:@"aTableViewCell"];
    [self.tabDataSource updateReloadData:@[@"111",@"222"]];
    */
}

##Cell方法

#import "JDragonTableManager.h"
@interface aTableViewCell ()<JDTableManagerDelegate>

@end

@implementation aTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)PrepareToWithAppear:(NSObject *)data WithCurentVC:(UIViewController *)curentVC WithIndexPath:(NSIndexPath *)indexPath
{
    self.textLabel.text = [data isKindOfClass:[NSString class]]?(NSString*)data:data.description;

    NSLog(@"data====%@",data);
}
@end

##详细请看demo

jdragontablemanager's People

Contributors

lyc59621 avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli 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.