我收到错误:无法识别的选择器发送到实例,经过检查,我发现此部分代码存在问题,更具体地说:[self.tableView insertSubview:ovController.view aboveSubview:self.parentViewController.view];
- (void) searchBarTextDidBeginEditing:(UISearchBar *)theSearchBar {
if(searching)
return;
//Add the overlay view.
ovController = [[OverlayViewController alloc] initWithNibName:@"OverlayView" bundle:[NSBundle mainBundle]];
CGFloat yaxis = self.navigationController.navigationBar.frame.size.height;
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
//Parameters x = origion on x-axis, y = origon on y-axis.
CGRect frame = CGRectMake(0, yaxis, width, height);
ovController.view.frame = frame;
ovController.view.backgroundColor = [UIColor grayColor];
ovController.view.alpha = 0.5;
ovController.rvController = self;
[self.tableView insertSubview:ovController.view aboveSubview:self.parentViewController.view];
searching = YES;
letUserSelectRow = NO;
//self.tableView.scrollEnabled = NO;
}
看起来tableview存在问题吗?
答案 0 :(得分:2)
我不确定为什么这会导致无法识别的选择器异常,但似乎不太可能[self.tableView insertSubview:ovController.view aboveSubview:self.parentViewController.view];可能是正确的。这只有在self.parentViewController.view是self.tableView的子视图时才有效。除非你对视图层次结构做了非常滥用的事情,否则这似乎是由内而外的。