您的位置:首页 > 产品设计 > UI/UE

UITableViewCell Storyboard加载错误解决

2015-09-11 09:43 501 查看
1. 当使用XIB文件时,使用Cell前需要在ViewDidLoad方法中注册
UINib *nib = [UINib nibWithNibName:CLASS_NAME bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier:CELL_IDENTIFIER_IN_XIB];

然后在cellForRowAtIndexPath中使用:
NewProductCell *cell = [self.tableView dequeueReusableCellWithIdentifier:<span style="font-family: Arial, Helvetica, sans-serif;">CELL_IDENTIFIER_IN_XIB </span><span style="font-family: Arial, Helvetica, sans-serif;">forIndexPath:indexPath];</span>


2. 当使用StoryBoard时,使用1的方法会出现错误:

NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/XXX/Library/Developer/CoreSimulator/Devices/2201F07B-8301-4164-8FE0-26EA82D9895C/data/Containers/Bundle/Application/79E7DC2C-ED24-4031-9AAC-10BE9BC9955D/xpyx.app>
(loaded)' with name 'NewProductCell'
解决方法是把ViewDidLoad中的注册部分删除掉,原因估计是在初始化ViewController时,已经自动注册了关联的Cell。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: