当 UIPopoverController 在屏幕上时,无法与包含结果的 UIPopoverController 的 UISearchBar 进行交互

发布于 2024-10-11 08:53:36 字数 277 浏览 12 评论 0原文

我有一个 UISearchBar。当用户触摸 UISearchBar 时,会显示一个 UIPopoverController,其中包含结果的 UITableView。当用户键入时,结果就会出现。

我希望用户能够触摸 UISearchBar 中的灰色 x 按钮来清除搜索结果并清除 UISearchBar 的文本字段。然而,第一次触摸只是关闭 UIPopoverController,提示用户再次触摸按钮以清除文本字段。

有没有办法在显示 UIPopoverController 时允许与其他对象进行触摸交互?

I have a UISearchBar. When the user touches the UISearchBar, a UIPopoverController is shown that contains a UITableView of results. As the user types, the results appear.

I want the user to be able to touch the grey x button in the UISearchBar to clear the search results and clear the UISearchBar's text field. However, the first touch simply dismisses the UIPopoverController, prompting the user to touch the button a second time to clear out the text field.

Is there a way to allow touch interaction with other object while a UIPopoverController is showing?

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

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

发布评论

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

评论(1

£烟消云散 2024-10-18 08:53:36

尝试将 UIPopoverController 的 passthroughViews 属性设置为 UISearchBar。

事实上,Apple 示例应用 ToolbarSearch 确实如此这:

// Ensure the popover is not dismissed if the user taps in the search bar.
popover.passthroughViews = [NSArray arrayWithObject:searchBar];

Try setting the passthroughViews property of the UIPopoverController to the UISearchBar.

In fact, the Apple sample app ToolbarSearch does exactly this:

// Ensure the popover is not dismissed if the user taps in the search bar.
popover.passthroughViews = [NSArray arrayWithObject:searchBar];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文