开发者

NSInvalidArgumentException Error When Using UITabBarController

开发者 https://www.devze.com 2023-03-11 21:22 出处:网络
I got the following error and I can\'t seem to figure out what happened.Please help me. Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'-[UIViewController tableVie

I got the following error and I can't seem to figure out what happened. Please help me.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:nu开发者_如何学运维mberOfRowsInSection:]: unrecognized selector sent to instance 0x57405a0'


If you're using:

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

Try:

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

And see what returns. Maybe the array is not been properly allocated.


This could be anything. It might be a delegate being called which does not implement the protocol, or it might be a memory leak where a call is made on some released memory. Hard to tell like this. Try compiling with "Analyze" and check all warnings.


I had a similar problem, but the solution was not associated with the numberOfRowsInSection: method as Xcode was pointing too.

Instead, the overriding problem was that I had not set my UIViewController's Custom Class setting... In my case it was empty instead of having a valid class name like "DetailsVC2" in the example image below. Once I corrected this issue the usual numberOfRowsInSection: operation is recognized and called correctly.

Typically, you want to return the count of an array (e.g. tableData), but in my very simple case I returned the value of 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;
}

NSInvalidArgumentException Error When Using UITabBarController

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号