2015-12-21 70 views
0

我在我的應用程序中使用自定義單元格(friendListCell)。當我運行這個IOS 8後來它工作,但在IOS 7它崩潰並顯示如下錯誤。我無法找出錯誤的地方存在,應用程序崩潰IOS 7工作IOS 8

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UILabel 0x17892a10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.' 

下面的代碼,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; 
    return cell; 
} 

注: 我刪除所有的引用,即使它會顯示錯誤這種細胞。

+1

向我們展示一些代碼,並指出崩潰發生的位置。請注意,您可能需要啓用異常斷點來查看觸發異常的原因。 – jcaron

+0

您可能試圖設置文本而不引用Label的文本屬性...您必須在某處執行'lblTitle = @「data」'而不是'lblTitle.text = @「data」'.. – Dalvik

+0

請參閱我的更新代碼和斷點顯示錯誤,當涉及到下面的行,單元格= [tableView dequeueReusableCellWithIdentifier:@「cell」forIndexPath:indexPath]; –

回答

0

該錯誤消息意味着,你從一個不存在的情節提要/廈門國際銀行文件中設置對一個UILabel的變量。

無論如何您都可以更改代碼並且不會解決問題。錯誤出現在storyboard或xib文件中。你是否想在storyboard/xib文件中設置一個名爲keyPath的變量?

+0

明白了!你改正了。我錯誤地將keypath添加到實際視圖控制器中呈現的uilabel。這應該導致錯誤。但它在IOS 8中工作。這讓我很困惑。嘲笑! –

+0

您在iOS 8中發現了一個無證的財產! –

0

試試這個創建細胞:

static NSString *CellIdentifier = @"cell"; 
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
    } 
+0

我以前使用過這個,但現在我想添加到故事板的標識符作爲「列表」,並將其稱爲像上面的代碼行...... –

+0

因此代替'cell'使用您的標識符'列表' – Dalvik

+0

仍然崩潰。 –