Iphone 使用UITabBarController时出现NSInvalidArgumentException错误

Iphone 使用UITabBarController时出现NSInvalidArgumentException错误,iphone,xcode,uitabbarcontroller,Iphone,Xcode,Uitabbarcontroller,我犯了以下错误,我似乎不知道发生了什么。请帮帮我 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIViewController tableView:numberOfRowsInSection:]:未识别的选择器发送到实例0x57405a0'这可能是任何内容。可能是调用的委托未实现协议,也可能是对某个已释放内存进行调用的内存泄漏。像这样很难说。尝试使用“分析”进行编译,并检查所有警告。如果您正在使用: - (NSInteger)tableV

我犯了以下错误,我似乎不知道发生了什么。请帮帮我


由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIViewController tableView:numberOfRowsInSection:]:未识别的选择器发送到实例0x57405a0'

这可能是任何内容。可能是调用的委托未实现协议,也可能是对某个已释放内存进行调用的内存泄漏。像这样很难说。尝试使用“分析”进行编译,并检查所有警告。

如果您正在使用:

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


看看有什么回报。可能数组没有正确分配。

我也遇到了类似的问题,但解决方案与Xcode指向的numberOfRowsInSection:方法没有关联

相反,最主要的问题是我没有设置我的UIViewController的自定义设置 类设置。。。在我的例子中,它是空的,而不是下面示例图像中的“DetailsVC2”这样的有效类名。一旦我纠正了这个问题,通常的numberofrowsin节:操作被正确识别和调用

通常,您希望返回数组的计数(例如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;
}

您正在对未实现协议的UIViewController调用UITableViewControllerDelegate方法(numberOfRowsInSection:)。这就是我们从你提供的信息中所能告诉你的一切。我们需要看看你是如何填充你的UITabBarController的。你想让我展示什么?对不起,我是Objective-C的新手。您从numberOfRowsInSection方法返回什么?-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{return[array count];}使用“Analyze”运行时,我没有任何泄漏。
NSArray *tableData; // Defined somewhere above, and populated prior to the viewDidAppear() operation

 .
 .
 .

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