简体   繁体   English

我在iOS UITableView中有NSInvalidArgumentException

[英]I have NSInvalidArgumentException in iOS UITableView

the error is: 错误是:

2013-04-02 14:46:07.180 ECom[7855:c07] -[UITableViewController setItemRow:]: unrecognized selector sent to instance 0x768c770
2013-04-02 14:46:07.180 ECom[7855:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewController setItemRow:]: unrecognized selector sent to instance 0x768c770'

In the method int the last line of the code: 在方法int的最后一行代码中:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"clPanelSegue"])
    {
        NSIndexPath *path = [self.tableView indexPathForSelectedRow];
        ECOMClPanelDetailViewController *detail = (ECOMClPanelDetailViewController*)segue.destinationViewController;
        NSLog(@"clPanelSeguePathRow = %d", path.row);
        [detail setItemRow:path.row];
    }
}

And the method in the last line is 最后一行的方法是

-(void)setItemRow:(int)aItemRow
{
    clDetailItemRow = aItemRow;
}

Can't understand what's wrong. 无法理解出了什么问题。 Who can help? 谁能帮忙?

First, it appears that your detail panel isn't what you think it is. 首先,您的详细信息面板似乎与您认为的不一样。 Based on the error message, the seque.destinationViewController is of class UITableViewController , not ECOMClPanelDetailViewController . 根据错误消息, seque.destinationViewControllerUITableViewController类,而不是ECOMClPanelDetailViewController类。 That's what you need to track down first. 这就是您首先需要查找的内容。

Second, because of this, when you send your setItemView: message, it can't be interpreted and raises the exception. 其次,因此,当您发送setItemView:消息时,将无法解释该消息并引发异常。

Begin by looking at where the `destinationViewController is instantiated (maybe your XIB file) and make sure that you have the right classes set. 首先查看`destinationViewController的实例化位置(可能是您的XIB文件),并确保设置了正确的类。

the detail is not a ECOMClPanelDetailViewController, but pointing to a UITableViewController. detail不是ECOMClPanelDetailViewController,而是指向UITableViewController。 You can check the segue's identifier in your storyboard to make sure you didn't make a mistake in the identifier name. 您可以在情节提要中检查segue的标识符,以确保您没有在标识符名称上输入错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM