【发布时间】:2013-11-04 07:01:33
【问题描述】:
我的故事板有问题。它工作正常,但是当我尝试更改 UITableView 的内容属性时,它导致以下错误
-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] 中的断言失败,/SourceCache/UIKit/UIKit-2903.23/UITableView.m 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将具有标识符 Cell 的单元格出列 - 必须为该标识符注册一个 nib 或一个类或连接故事板中的原型单元格”
我想设计一个带有静态单元格的分组表格视图。提前致谢
代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
【问题讨论】:
-
如果您不分享您的代码,我们将无法为您提供帮助
-
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // 返回节数。返回 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];返回单元格; }
-
@AdnanChaudhry :将代码添加到问题中,您可以编辑问题并添加这样的代码..查看问题下的编辑选项
-
更多信息请见link。