我有UISearchBar
响应TouchesBegan
而不是委托方法 ..我已在代码中设置其委托
self.searchbar.delegate = self;
并将其连接到IB
我已经实现了以下委托方法
-(void)searchBarCancelButtonClicked:(UISearchBar *)aSearchBar { }
-(void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar { }
-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)aSearchBar { }
-(BOOL)searchBarShouldEndEditing:(UISearchBar *)aSearchBar { }
-(void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)text { }
touchesBegan方法是
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
答案 0 :(得分:0)
您必须将自定义委托指向您的对象:
将self.searchbar.delegate = self;
替换为self.searchbar.yourCustomDelegate = self;
答案 1 :(得分:0)
对于那些遇到这个问题的人..我唯一能够得到的工作是改变[self.taber tleView setUserInteraction:NO]
;到self.tableView.allowsSelection = YES;
..这不允许SearchBar调用其委托方法..在更改上面的行之后,UISearchbar
最终能够在触摸时调用其委托方法。