UI_cell 注册问题

来源:互联网 发布:冰点降低数据法 编辑:程序博客网 时间:2024/05/22 06:15

如果用方法:

[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];    }
1 0
原创粉丝点击