- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
//被static修饰的局部变量,只会初始一次。整够运行过程中只有一份内存
staticNSString*ID =@"cell";
//1、先根据Cell的标识符去缓存池中查找可以利用的Cell
UITableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:ID];
//如果Cell为空创建Cell并给相应的标识符
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
}
//3、数据覆盖
cell.textLabel.text= [NSStringstringWithFormat:@"%zd",indexPath.row];
NSLog(@"%p-----%zd",cell, indexPath.row);
returncell;
}
网友评论