原因:"无法使用标识符取消单元格的排队



我在 Xcode 中运行我的应用程序时收到错误消息(由于未捕获的异常而终止应用程序)。下面我粘贴了错误消息,我认为是造成问题的代码部分。我是新手,只是学习目标c,所以请对我轻松。谢谢!

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); Thread 1:signal SIGABRT
    }
}
  • 错误消息:

    2014-11-25 10:07:19.794 SamplePhotoReDo[81276:108898068] * 断言失败 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:],/SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableView.m:61162014-11-25 10:07:19.798 SamplePhotoReDo[81276:108898068] * 由于未捕获的异常"NSInternalInconsistencyException"而终止应用程序,原因:"无法使用标识符AllPhotosCell 取消对单元格的排队 - 必须为标识符注册笔尖或类,或者在情节提要中连接原型单元格"第一个抛出调用堆栈:'

我认为导致错误的脚本:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    NSString *localizedTitle = nil;
    if (indexPath.section == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:AllPhotosReuseIdentifier forIndexPath:indexPath];
        localizedTitle = NSLocalizedString(@"All Photos", @"");
    } else {
        cell = [tableView dequeueReusableCellWithIdentifier:CollectionCellReuseIdentifier forIndexPath:indexPath];
        PHFetchResult *fetchResult = self.collectionsFetchResults[indexPath.section - 1];
        PHCollection *collection = fetchResult[indexPath.row];
        localizedTitle = collection.localizedTitle;
    }
    cell.textLabel.text = localizedTitle;
    return cell;
}

in ViewDidLoad 添加:

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:AllPhotosReuseIdentifier];

相关内容

最新更新