首页 > 其他 > 详细

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法意思

时间:2015-04-16 19:08:46      阅读:433      评论:0      收藏:0      [点我收藏+]
这个方法是用来设置你的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;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法意思

原文:http://www.cnblogs.com/daijiahong/p/4432727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!