TableView unable to dequeue a cell with identifier Cell - must register a class or Nib
2014-09-06 09:53
375 查看
最近一直在学习UIKit 框架,里面的功能真的是很强大,所以决定尝试了 一下tableViewController 。
可是遇到了很多问题。
BUG:TableView unable to dequeue a cell with identifier Cell - must register a class or Nib
BUG大概是在告诉我们UITableVIew并没有注册一个类,或者说我们找不到这样一个UItableView。
那我们来看一下registerclass
我们来看看官方的注释
1 // Beginning
in iOS 6, clients can register a nib or class for each cell. 2 // If
all reuse identifiers are registered, use the newer -dequeueReusableCellWithIdentifier:forIndexPath: to guarantee that a cell instance is returned. 3 // Instances
returned from the new dequeue method will also be properly sized when they are returned. 4 -
(void)registerNib:(UINib
*)nib forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(5_0); 5 -
(void)registerClass:(Class)cellClass
forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
大致的译文:我们可以为每个cell 注册nib 或类,如果所有的复用Identifiers都注册过了,可以尝试一下新的方法dequeueReusableCellWithIdentifier:forIndexPath: ,确保每一个cell都被返回。
看来我们一定要给tableView注册了。
我在ViewDidLoad里面为tableView加了一句
[self.tableView registerClass[UITableVIewCell Class]forCellReuseIdentifier:@"SimpleTable"];//这里的ReuseIdentifier
一定要跟代理方法里的保持一致,不然还是找不到你的UITableVIewCell.
运行一下,问题果然解决了.
可是遇到了很多问题。
BUG:TableView unable to dequeue a cell with identifier Cell - must register a class or Nib
BUG大概是在告诉我们UITableVIew并没有注册一个类,或者说我们找不到这样一个UItableView。
那我们来看一下registerclass
我们来看看官方的注释
1 // Beginning
in iOS 6, clients can register a nib or class for each cell. 2 // If
all reuse identifiers are registered, use the newer -dequeueReusableCellWithIdentifier:forIndexPath: to guarantee that a cell instance is returned. 3 // Instances
returned from the new dequeue method will also be properly sized when they are returned. 4 -
(void)registerNib:(UINib
*)nib forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(5_0); 5 -
(void)registerClass:(Class)cellClass
forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
大致的译文:我们可以为每个cell 注册nib 或类,如果所有的复用Identifiers都注册过了,可以尝试一下新的方法dequeueReusableCellWithIdentifier:forIndexPath: ,确保每一个cell都被返回。
看来我们一定要给tableView注册了。
我在ViewDidLoad里面为tableView加了一句
[self.tableView registerClass[UITableVIewCell Class]forCellReuseIdentifier:@"SimpleTable"];//这里的ReuseIdentifier
一定要跟代理方法里的保持一致,不然还是找不到你的UITableVIewCell.
运行一下,问题果然解决了.
相关文章推荐
- UITableView 的一个常见错误'unable to dequeue a cell with identifier Cell - must register a nib or a class f
- unable to dequeue a cell with identifier xxx - must register a nib or a class fo
- UITableViewCell unable to dequeue a cell with identifier Cell - must register a nib or a class for t
- unable to dequeue a cell with identifier xxx - must register a nib or a class for the identifier
- UITableViewCell unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell
- unable to dequeue a cell with identifier - must register a nib or a class for the identifier...问题
- unable to dequeue a cell with identifier Identify - must register a nib or a class for the identifie
- unable to dequeue a cell with identifier cell - must register a nib or a class for the identifier or
- swift写一个简单的列表unable to dequeue a cell with identifier reuseIdentifier - must register a nib or a cla
- UITableView使用注意事项(unable to dequeue a cell with identifier)
- must register a nib or a class for the identifier or connect a prototype cell in a storyboard'的解决办法
- unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
- 哈02—kill error_______unable to dequeue a cell with identifier Cell
- Xcode unable to dequeue a cell with identifier
- Q6:关于xcode TableView使用Nib文件出现Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:错误
- unable to dequeue a cell with identifier shopCell
- Xcode error: unable to dequeue a cell with identifier cell
- [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]IOS6.0以上
- 关于tableview的 [self.tableView registerClass: forCellReuseIdentifier:使用方法
- [ios]tableView内部cell因内容大小变换 而变化 sizeWithFont:constrainedToSize: lineBreakMode: