UITableViewCell出错

时间:2010-10-27 16:02:09

标签: iphone objective-c

我收到错误:

* 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [NSNull isEqualToString:]:无法识别的选择器发送到实例0x26e9d68'

我有一个FriendViewCell类,它有一个UIImageView和另外两个标签作为IBOutlet。设置属性并合成它(基本的东西)。我已将插座连接到相应的标签和imageview,并将类类型更改为FriendViewCell,同时将标识设置为

我的部分代码如下:

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

if (cell == nil) {
    NSArray *topLevelObjects = [[NSBundle mainBundle] 
                                    loadNibNamed:@"FriendViewCell"
                                    owner:nil options:nil];

        for (id currentObject in topLevelObjects){
                if ([currentObject isKindOfClass:[UITableViewCell class]]) {
                    cell = (FriendViewCell *) currentObject;
                    break;
                }
        }
    }

2 个答案:

答案 0 :(得分:0)

您是否尝试使用分配跟踪找到实例0x26e9d68的内容?

答案 1 :(得分:0)

您可以简单地将一个IBOutlet添加到tableviewcontroller中,而不是抓住数组并搜索您的单元格吗?

@property (nonatomic, assign) IBOutlet UITableViewCell *tvCell;

然后在代码中:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FriendViewCell"];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"FriendViewCell" owner:self options:nil];
    cell = tvCell;
}

您需要将IBOutlet链接到Interface Builder中的单元格。