- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法意思
2015-04-16 17:29
591 查看
这个方法是用来设置你的TableView中每一行显示的内容和格式的。
indexPath 用来指示当前单元格,它的row方法可以获得这个单元格的行号,section方法可以获得这个单元格所处的区域号
static NSString *CellIdentifier = @"cell";//可复用单元格标识
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
NSInteger sectionNumber = [indexPath section];//分组的tableView里才有用
NSInteger rowNumber = [indexPath row];
cell.textLabel.text = [[myDataSource objectAtIndex:sectionNumber] objectAtIndex:rowNumber];//设置当前单元格的显示内容
cell.textLabel.textColor = [UIColor greenColor];//设置当前单元格的显示字体的颜色
}
return cell;
indexPath 用来指示当前单元格,它的row方法可以获得这个单元格的行号,section方法可以获得这个单元格所处的区域号
static NSString *CellIdentifier = @"cell";//可复用单元格标识
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
NSInteger sectionNumber = [indexPath section];//分组的tableView里才有用
NSInteger rowNumber = [indexPath row];
cell.textLabel.text = [[myDataSource objectAtIndex:sectionNumber] objectAtIndex:rowNumber];//设置当前单元格的显示内容
cell.textLabel.textColor = [UIColor greenColor];//设置当前单元格的显示字体的颜色
}
return cell;
相关文章推荐
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行的问题
- 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UITableViewCell注册(填写)重用标识符:identifier.必须要代码方法中的标识符一致.
- 使用自定义的tableViewCell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
- UITableView不掉用tableView: cellForRowAtIndexPath方法
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath
- Ios 自定义表示图出现的相关问题UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath
- 关于错误 reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- iOS 开发,UITableViewController中手势关闭cell中的键盘。且不影响tableView中的 didSelectRowAtIndexPath 方法。
- tableView代理方法的调用时间,(主要是heightForRowAtIndexPath和cellForRowAtIndexPath调用时间)
- 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
- 关于UITableView 不能回调 tableView: cellForRowAtIndexPath的问题
- tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
- 【iOS】tableView:cellForRowAtIndexPath: 方法未调用
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath
- -tableView: cellForRowAtIndexPath:方法不执行问题
- Ios 该图显示其出现的相关问题定义UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- UITableView reloadData后,cellForRowAtIndex方法未调用问题