我创建了一个 tableviewcontroller 来处理 tableview 中的 4 个静态单元格。表格视图位于 4 个单元格的正下方。但是,最后一个单元格,即第 4 个单元格,根据第 3 个单元格的结果是可选的。
选择器返回一个值,如果值正确,它会重新加载表格视图以激活第 4 个单元格。
当我运行应用程序时,它会在加载 SettingsViewController 时崩溃,并出现以下错误:
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将具有标识符 Cell 的单元格出列 - 必须为标识符注册 nib 或类或连接情节提要中的原型单元格”
如果我有静态单元格,我认为我不需要重用标识符?
以下是相关代码:
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(self.showLastCell)
{
return 4;
}
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}