// 这个方法的模板
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//cell的标示符
// 以后表格中可能有不同样式的cell, 区分样式的cell
static NSString *cellID = @"cell";
//获取一个以前用过的cell, 现在没有用
// 相当于从后厨获取一个碗
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if(cell == nil) //没碗可取
{
//参数 initWithStyle设置风格,共有4种
//样式: Default,Value1,Value2,Subtitle
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID] autorelease];
}
//此处放上你的显示数据的代码
return cell;
}
iOS开发表格的复用机制
最新推荐文章于 2022-04-17 16:46:40 发布