gpt4 book ai didi

ios - 为标识符(单元格)注册的无效 Nib

转载 作者:行者123 更新时间:2023-11-28 17:54:07 28 4
gpt4 key购买 nike

当我将 segue 拖到另一个要推送的 View Controller 时,我的 UITableView 出现以下错误。

"invalid nib registered for identifier (Cell) - nib must contain exactly one top level object which must be a `UITableViewCell` instance"

我的 Storyboard上有一个 UITableView。我通过 Storyboard在 UITableView 中放入了两个静态行。我通过 Storyboard 为这些行指定了“Cell”的 cellIdentifier。

这是我的 cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

[cell.textLabel setFont:[UIFont fontWithName:@"GothamRounded-Light" size:18]];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 13, 300, 30)];
label.textColor = [UIColor statLightBlue];
[label setFont:[UIFont fontWithName:@"Rounded-Light" size:18]];
[cell.contentView addSubview:label];

if(indexPath.row == 0){
label.text = @"Credit Card"; // man profile
cell.imageView.image = [UIImage imageNamed:@"CreditCardIcon.png"];
} else if (indexPath.row == 1) {
label.text = @"Promotion Code"; // credit card
cell.imageView.image = [UIImage imageNamed:@"PromoCodeIcon.png"];
}

return cell;
}

至此,一切正常。但这是导致上述错误的原因:

如果我控制从 Storyboard中的第一个 UITableView 单元格拖动到创建 segue 的任何其他随机 View ,则会导致上述错误。如果我删除所说的 segue,错误就会消失。

关于我做错了什么的任何线索?

最佳答案

问题是你给了“CELL”而没有“Cell”也仔细检查了你是否在 IB 或 Restoration ID 中设置了标识符,你必须设置的标识符在“属性检查器”中

关于ios - 为标识符(单元格)注册的无效 Nib ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19819234/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com