Я смотрю на многие ответы и до сих пор не могу понять. Я знаю, что первая линия это немного странно, но его потому, что он наследует от суперкласса, который устанавливает headerview в строке поискаПочему UIButton не отвечает на касания?
searchBar = (UISearchBar *)self.tableView.tableHeaderView;
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, -100, self.view.frame.size.width, 100)];
label.text = @"AAAA";
[searchBar addSubview:label];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(aMethod)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, -60, 160.0, 40.0);
searchBar.exclusiveTouch = NO;
searchBar.userInteractionEnabled = NO;
label.userInteractionEnabled = NO;
button.userInteractionEnabled = YES;
[searchBar insertSubview:button atIndex:3];
попытаться установить 'searchBar.userInteractionEnabled = YES;' вместо –
Я пытался, что и он не работает – mergesort
Также пробовал и не работает – mergesort