【发布时间】:2015-02-13 08:05:39
【问题描述】:
加载表格视图时出现此错误,但我不确定原因:
-[UITableView 中的断言失败 _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableView.m:7344
我在情节提要中添加了UITableViewController,并且正在使用原型单元来设计单元。我将单元格链接到我的自定义UITableViewCell 子类,并将其重用标识符设置为“单元格”。当我在cellForRowAtIndexPath 中调用dequeueReusableCellWithIdentifier 时出现断言失败。根据我的阅读,当我没有在原型单元中设置重用标识符时会发生这种情况,但是我已经检查了无数次,并且它与我在将其出列时使用的标识符相同。
这是我在 UITableViewController 子类中的数据源方法:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LanguageSelectionTableViewCell *cell = (LanguageSelectionTableViewCell*)[self.tableView dequeueReusableCellWithIdentifier:@"Cell"];
return cell;
}
【问题讨论】:
-
尝试在情节提要中添加单元格标识符
-
@Sam 我在情节提要的原型单元格中添加了一个名为“Cell”的标识符
-
如果可行,请尝试更改 Cell 以外的标识符名称
-
你能在 Dropbox 上分享示例应用吗
标签: ios objective-c iphone uitableview cocoa-touch