美文网首页
tableView 的cell 重用机制

tableView 的cell 重用机制

作者: zcaaron | 来源:发表于2016-07-08 20:20 被阅读159次

-------> dequeueResableCellWithIdentifier方法

//一般对table view的数据都进行绑定,需要填充多个cell,自动调用n次 ,超过屏幕 ,需要对cell 设置重用机制.

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

UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"FlipsideCellIdentifier"];

if (cell == nil) {

cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"FlipsideCellIdentifier"] autorelease];    //  如果是在ARC模式下不需要写autorelease.

}

cell.text = [soundSignatures objectAtIndex:indexPath.row];

return cell;

}

相关文章

网友评论

      本文标题:tableView 的cell 重用机制

      本文链接:https://www.haomeiwen.com/subject/fxjrjttx.html