如果用方法:
[tableView dequeueReusableCellWithIdentifier:(NSString *) forIndexPath:(NSIndexPath *)];
定义cell ,会出现下面错误提示信息
Terminating app due to uncaught exception ‘NSInternalInconsistencyException‘, reason: ‘unable to dequeue a cell with identifier ActiveListCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard‘
此时需要注册
[tableView registerClass:[ActiveTableViewCell class] forCellReuseIdentifier:@"ActiveListCell"];
如果用方法:
[tableView dequeueReusableCellWithIdentifier:(NSString *)];
则可以不必注册,但是要写判断
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"ActiveTableViewCell" owner:self options:nil] firstObject];
}
版权声明:本文为outlan原创文章,未经博主允许不得转载。
时间: 2024-10-31 06:41:31