簡體   English   中英

使用 UITabBarController 時出現 NSInvalidArgumentException 錯誤

[英]NSInvalidArgumentException Error When Using UITabBarController

我收到以下錯誤,我似乎無法弄清楚發生了什么。 請幫我。

由於未捕獲的異常“NSInvalidArgumentException”而終止應用程序,原因:“-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x57405a0”

如果您正在使用:

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [array count]; } –

嘗試:

NSLog(@"%i", [array count]);

看看有什么回報。 也許數組沒有被正確分配。

我有一個類似的問題,但解決方案與numberOfRowsInSection無關:方法 Xcode 也指向。

相反,最重要的問題是我沒有設置我的 UIViewController 的自定義 Class設置......在我的情況下,它是空的,而不是像下面示例圖像中的“DetailsVC2”這樣的有效 class 名稱。 一旦我糾正了這個問題,通常的numberOfRowsInSection:操作就會被識別並正確調用。

通常,您希望返回數組的計數(例如 tableData),但在我非常簡單的情況下,我返回了 1 的值。

NSArray *tableData; // Defined somewhere above, and populated prior to the viewDidAppear() operation

 .
 .
 .

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return 1; // or tableData.count;
}

在此處輸入圖像描述

這可以是任何東西。 它可能是被調用的未實現協議的委托,或者可能是 memory 泄漏,其中調用了一些已發布的 memory。 很難說這樣。 嘗試使用“分析”進行編譯並檢查所有警告。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM