Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么我的tableview在标识符上崩溃?_Ios_Uitableview_Reuseidentifier - Fatal编程技术网

Ios 为什么我的tableview在标识符上崩溃?

Ios 为什么我的tableview在标识符上崩溃?,ios,uitableview,reuseidentifier,Ios,Uitableview,Reuseidentifier,我创建了一个tableviewcontroller来处理tableview中的4个静态单元格。tableview位于4个单元格的正下方。但是,根据第三个单元格的结果,最后一个单元格第四个单元格是可选的 选择器返回一个值,如果该值正确,它将重新加载tableview以激活第四个单元格 当我运行应用程序时,它在加载SettingsViewController时崩溃,并出现以下错误: 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将具

我创建了一个tableviewcontroller来处理tableview中的4个静态单元格。tableview位于4个单元格的正下方。但是,根据第三个单元格的结果,最后一个单元格第四个单元格是可选的

选择器返回一个值,如果该值正确,它将重新加载tableview以激活第四个单元格

当我运行应用程序时,它在加载SettingsViewController时崩溃,并出现以下错误:

由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将具有标识符单元格的单元格出列-必须为标识符注册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;
}

出列单元格用于具有动态单元格的表视图。静态单元格表视图不需要数据源CellForRowatineXpath。因此,您可以安全地删除数据源方法cellForRowAtIndexPath

检查此问题以了解更多说明:


或者您可以使用这里提到的super方法:

您不需要将其出列,正如您所说的,它只是静态单元格

而不是:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
使用:

祝你好运

编辑:太慢了

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];