我的标题中有一个 UITableView 和一个 UISearchBar。当用户在 UISearchBar 中单击时,我创建一个 View (bg: black, alpha .65) 并将其放置在 UITableView 中的内容上。我想要的是当用户单击这个半透明的 UIView 时,从 UISearchBar 中退出第一响应者。我已经在我的 UIViewController(也是我的 UITableView 的 Controller )中实现了 touchesEnded:withEvent:
,但是这个函数从未被调用过。我在这里遗漏了什么吗?
干杯,
罗布
最佳答案
你的 Controller 只会处理它自己的 View 的事件,这可能是 TableView 。如果你想在后面添加的 View 中处理触摸事件,你需要继承 UIView 并实现 touchesEnded:withEvent:
方法。
关于iphone - touchesEnded :withEvent: not being called from my UIView, 位于 UITableView 之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4518414/