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;
}