0

对于带有 UISearchDisplayController 的 UISearchBar,当单击搜索字段时,会出现键盘并在 tableview 上显示一个叠加层。单击取消时

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar

叫做。

我想知道单击叠加层时是否调用了一个方法。它确实关闭了键盘并返回到 tableview。基本上我想让单击此叠加层运行与单击取消时相同的方法。有任何想法吗?我检查了 Apple Docs,除了取消按钮方法之外找不到任何东西。

4

2 回答 2

1
  1. 您可以继承 UISearchDisplayController 并从touchesBegan 方法调用此取消方法:

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    
  2. 您可以将UITapGestureRecognizer分配给 overlayView。

于 2013-02-05T00:13:26.600 回答
1

*取消:只是 [self.searchDisplayController setActive:NO]; 并在 touchesBegan 中实现它,就像 ToMfromTO 的答案一样。

于 2013-02-05T00:09:12.820 回答