2013-02-22 33 views
3

我收到錯誤,如
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The NIB data is invalid.''NSInternalInconsistencyException',原因:'NIB數據無效'。對於CustomCell

對於iOS 5.0,即使我取消了自動版式,併爲所有版本的iOS爲customcell部署支持。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 

     static NSString *CustomCellIdentifier = @"GroupListCell"; 

     GroupListCell *cell = (GroupListCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier]; 

      if (cell == nil) 
      { 
       NSArray *nib; 

       if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) 
       { 
        nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListCell" owner:self options:nil]; 
       } 
       else{ 
        nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListiPhoneCell" owner:self options:nil]; // sigabrt 
       } 
       // cell implementation code.. 
      } 
} 

此代碼適用於iOS6.0,但不適用於iOS 5.0。
問題是什麼?我錯過了什麼。

回答

2

最後,我發現這個問題。

我的單元格中有一個textview,即使Text屬性被定義爲「Plain」,它也具有文本屬性。它在「平原」中沒有改變。因爲手動更改文本,並使用enter關鍵字轉到下一行。它在內部被認爲是「歸因」。

因此檢查TextView 2次的文本屬性。 :)

1

提取單元格的代碼可能會丟失在您的案例中。希望以下糾正的代碼有效。在下面的圖中設定值

if (cell == nil) 
      { 
       NSArray *nib; 

       if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) 
       { 
        nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListCell" owner:self options:nil]; 

        cell = [nib objectAtindex:0]; 
       } 
       else{ 
        nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListiPhoneCell" owner:self options:nil]; // sigabrt 
        cell = [nib objectAtindex:0]; 
       } 
       // cell implementation code.. 
      } 
+0

我會嘗試 – KDeogharkar 2013-02-22 07:11:30

+0

不能正常工作,它只會將sigabrt放在上面,以避免您添加的特定行。 – KDeogharkar 2013-02-22 07:13:10

+0

把一個異常斷點,並檢查確切地得到錯誤的地方 – 2013-02-22 07:16:31

15

檢查筆尖文件
enter image description here

檢查UILabelUIButton文本也

enter image description here

+0

是的,它已經以這種方式設置。我在我的問題中提到過它 – KDeogharkar 2013-02-22 08:01:40

+0

你在筆尖上是否有任何標籤或按鈕? – 2013-02-22 08:16:29

+0

是的,我有..... – KDeogharkar 2013-02-22 08:23:30

4

一段時間AutoLayout也可能導致問題。所以採取xib文件 - 檢查器窗格 - 取消勾選autolayout

1

對於較低版本的iOS 6可能會發生。

爲了解決這個問題

選擇故事板,然後

File Inspector - >Interface Builder Document取消選中Use Auto Layout

File Inspector - >Localization取消選中Base和檢查English

相關問題