touchesEnded:withEvent: 没有从我的 UIView 中调用,它位于 UITableView 之上

发布于 2024-10-08 21:58:13 字数 297 浏览 0 评论 0原文

我的标题中有一个 UITableView 和一个 UISearchBar 。当用户单击 UISearchBar 时,我创建一个视图(bg:黑色,alpha .65)并将其放置在 UITableView 中的内容上。我想要的是当用户单击这个半透明 UIView 时,从 UISearchBar 中退出第一响应者。我已经在我的 UIViewController (也是我的 UITableView 的控制器)中实现了 touchesEnded:withEvent: 但这个函数永远不会被调用。我在这里缺少什么吗?

干杯,

罗布

I have a UITableView and a UISearchBar in its header. When the user clicks in the UISearchBar I create a view (bg: black, alpha .65) and place it over the content in the UITableView. What I want is when the user clicks this semi transparent UIView is to resign the first responder from the UISearchBar. I have implemented touchesEnded:withEvent: in my UIViewController (is also my UITableView's controller) but this function never get called. Is there something I'm missing here?

Cheers,

Rob

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

高速公鹿 2024-10-15 21:58:13

您的控制器将仅处理其自己的视图(可能是表视图)的事件。如果你想在后面添加的视图中处理触摸事件,你需要继承 UIView 并实现 touchesEnded:withEvent: 方法。

Your controller will only handle events of its own view, which is probably the table view. If you want to handle touch events in the view you have added later, you need to subclass UIView and implement touchesEnded:withEvent: method.

飘逸的'云 2024-10-15 21:58:13

我找到了一个很好的链接,这个链接可以帮助你吗?
下载源代码以获得进一步帮助

使用 UISearchBar 和 UITableView 构建 SearchView
http://jduff.github。 com/2010/03/01/building-a-searchview-with-uisearchbar-and-uitableview/

i found a good link , may this link help you,
download the source code for further help

Building a SearchView with UISearchBar and UITableView
http://jduff.github.com/2010/03/01/building-a-searchview-with-uisearchbar-and-uitableview/

不知在何时 2024-10-15 21:58:13

您需要使用 UISearchBarController 而不是 UISearchBar,它具有您要查找的内置功能。

You need to use UISearchBarController insted of UISearchBar,This having builtin functionality for what you looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文