您的位置:首页 > 其它

tableView简单建立

2015-12-25 14:16 330 查看
1:代码

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 1;

}// Default is 1 if not implemented

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

return self.userRoleArray.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString * cellIdentifile = @"JJRoleTableViewCell";

JJRoleTableViewCell * roleCell =[tableView dequeueReusableCellWithIdentifier:cellIdentifile];

if (roleCell==nil) {

roleCell = [[JJRoleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifile];

}

[roleCell loadData:self.userRoleArray[indexPath.row]];

return roleCell;

}

----

cell:

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{

self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

if (self) {

}

return self;

}

2:xib

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 1;

}// Default is 1 if not implemented

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

return self.userRoleArray.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString * cellIdentifile = @"JJRoleTableViewCell";

JJRoleTableViewCell * roleCell =[tableView dequeueReusableCellWithIdentifier:cellIdentifile];

if (roleCell==nil) {

roleCell = [[[NSBundle mainBundle]loadNibNamed:cellIdentifile owner:self options:nil]firstObject];

}

[roleCell loadData:self.userRoleArray[indexPath.row]];

return roleCell;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: