objective-c – 发送到实例Custom Cell的无法识别的选择器

前端之家收集整理的这篇文章主要介绍了objective-c – 发送到实例Custom Cell的无法识别的选择器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试为我的UITableView制作自定义单元格.

所以,我创建了一个类(UITableViewCell),并命名为HomeCell.该类有一个xib文件,标签名为titleCell.

在我的cellForRowAtIndexPath方法中,我写道:

HomeCell *cell = (HomeCell *)[tableView dequeueReusableCellWithIdentifier:@"HomeCell"];

    if(cell == nil){
        NSArray *xib = [[NSBundle mainBundle] loadNibNamed:@"HomeCell" owner:self options:nil];
        for(id oneObject in xib){
            if([oneObject isKindOfClass:[HomeCell class]]){
                cell = (HomeCell *) oneObject;
            }
        }
    }

    //Get object at index data
    HomeObjectCell *tempObject = [self.dataForCell objectAtIndex:indexPath.row];

    NSLog(@"Title : %@",tempObject.title); // The tempObject.title return a NSString example

    cell.titleCell.text = tempObject.title; // <-- ERROR !

当我运行应用程序时,我得到了:

[UITableViewCell titleCell]: unrecognized selector sent to instance 0x6e61890

任何的想法?

解决方法

你绝对确定:

1)..你的班级“HomeCell”被命名为表格单元格正确吗?选择单元格,选择“身份检查员” – > “自定义类”部分,看一看

2)..引用与每个标签/ ui图像连接的插座?尝试再次选择您的单元格,选择“连接检查器”并查看

猜你在找的Xcode相关文章