2010-10-27 32 views
0

我得到的錯誤:由於未捕獲的異常 'NSInvalidArgumentException',原因誤差的UITableViewCell

*終止應用程序: ' - [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; 
       } 
     } 
    } 

回答

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中的單元格。

0

您是否嘗試過使用Allocations跟蹤來查找實例0x26e9d68的內容?