ios - iOS SwiftUI 上的 Mapbox 自动完成功能
问题描述
我正在开发一个基于 swift UI 的 iOS 应用程序。我想在其中拥有 Mapbox 自动完成功能。我尝试集成mapbox-search-SDK,但它似乎不支持 swift UI。
有什么我可以做的吗?这有可能吗?我也不可能恢复到另一个地图提供商。提前致谢。
解决方案
Mapbox 搜索 ui 在 UIKit 中完成,您可以使用or包装任何UIView
or 。UIViewController
UIViewRepresentable
UIViewControllerRepresentable
这是一个例子:
struct SearchControllerView: UIViewControllerRepresentable {
typealias UIViewControllerType = MapboxSearchController
func makeUIViewController(context: Context) -> MapboxSearchController{
MapboxSearchController()
}
func updateUIViewController(_ uiViewController: MapboxSearchController, context: Context) { }
}
struct SearchControllerView_Previews: PreviewProvider {
static var previews: some View {
SearchControllerView()
}
}
推荐阅读
- java - 如何使用 JPA/Hibernate 从 MySQL 数据库中检索其描述或名称包含某些给定单词的产品列表?
- ember.js - 如何强制 ember.js 在渲染索引路由之前完全加载所有路由?
- javascript - 键值配对数组元素在给定索引javascript中分配值时返回“未定义”错误
- python - 如何过滤收件箱并仅下载带有附件的电子邮件
- azure - terraform azurerm 函数应用程序设置 host.json 文档丢失
- android - Telegram JNI 在应用程序中检测到错误:从 UserConfig 和 define.h 更改 max_account_count 后线程线程
- java - 如何使用 Azure SDK 将私有 vnet 或子网与 Java 中的容器实例连接起来?
- javascript - 即使在其上绘制了另一个图像,背景图像也会保留
- opengl - OpenGL重叠丑陋渲染
- java - Spring-Boot Thymeleaf 以 html 格式加载图像,列表不显示