- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 Google places 和 autocomplete 操作,关于 Google places 的自动完成我得到了结果,但我希望将结果放在 Google map 前面的带有表格 View 的搜索栏中,就像弹出窗口一样。但我刚刚找到了带有搜索栏和表格 View 的示例,以及它们背后的其他内容。我期待着做如下图所示的事情。
Example about pop up with table view in front of maps
如有任何帮助,我们将不胜感激。
最佳答案
注意:我个人从未这样做过,但这是我的理论:
UISearchBar 是一个漂亮的工具,您可以将委托(delegate)连接到它来控制它的操作。以下是可在此处找到的文档的屏幕截图:link .
所以,我要做的是将 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/
我是一名优秀的程序员,十分优秀!