gpt4 book ai didi

swift - 在搜索栏中弹出表格 View ,swift 2

转载 作者:搜寻专家 更新时间:2023-11-01 05:36:51 24 4
gpt4 key购买 nike

我正在尝试使用 Google places 和 autocomplete 操作,关于 Google places 的自动完成我得到了结果,但我希望将结果放在 Google map 前面的带有表格 View 的搜索栏中,就像弹出窗口一样。但我刚刚找到了带有搜索栏和表格 View 的示例,以及它们背后的其他内容。我期待着做如下图所示的事情。

Example about pop up with table view in front of maps

如有任何帮助,我们将不胜感激。

最佳答案

注意:我个人从未这样做过,但这是我的理论:

UISearchBar 是一个漂亮的工具,您可以将委托(delegate)连接到它来控制它的操作。以下是可在此处找到的文档的屏幕截图:link .

screenshot

所以,我要做的是将 UISearchBar 设置为它周围的类。然后,实现您的委托(delegate)方法,以便在调用上面图片中显示的任何这些方法时,周围的类将转至 UIPopoverPresentationController,而后者又将在其中包含一个 UITableView。 (弹出窗口将从字面上“弹出”屏幕的其余部分。)

您必须确保您设置为委托(delegate)的类实现了 UISearchBarDelegate 协议(protocol)。它看起来像这样:

class Foo: UISearchBarDelegate {
/* stuff */
}

之后,所有的数据配置都由你决定。同样,这都是理论上的,因为我自己还没有真正实现过。如果我有任何错误,请告诉我。

祝你好运。

编辑:为了回应 Dan L 对最初问题的评论,实际上可以在 iPhone(或任何紧凑型屏幕)上显示弹出窗口而无需进入模式。您必须将呈现类设置为 UIPopoverPresentationController 的委托(delegate),然后实现如下委托(delegate)方法:

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}

所有代码所做的都是防止弹出框永远变成模态。

关于swift - 在搜索栏中弹出表格 View ,swift 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36532948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com