xib自定义cell

// 0.用static修饰的局部变量,只会初始化一次

staticNSString*ID =@"cell";//注意cell中,它的identifier设置为“cell”

// 1.拿到一个标识先去缓存池中查找对应的Cell

TableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:ID];

// 2.如果缓存池中没有,才需要传入一个标识创建新的Cell

if(cell ==nil) {

//通过xib文件来加载cell

NSBundle*bundle = [NSBundlemainBundle];//加载cell的xib文件

NSArray*objs = [bundleloadNibNamed:@"TableViewCell"owner:niloptions:nil];

cell = [objslastObject];

}

cell.selectionStyle=UITableViewCellSelectionStyleNone;

returncell;

你可能感兴趣的:(xib自定义cell)