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;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容