小编tom*_*rth的帖子

有人可以使用 SwiftUI+MapKit+LongPress 吗?

我正在尝试让SwiftUI+ MapKit+LongPress手势正常工作。当我在 中添加地图时ContentView,效果很好。然后,我将.onLongPressGesture修改器添加到地图中,平移/缩放停止工作。长按虽然有效。

我正在处理的代码:

Map(coordinateRegion: $region, interactionModes: .all, showsUserLocation: true)
  .onLongPressGesture {
    // How do I get the location (Lat/Long) I am pressed on?
    print("onLongPressGesture")
  }
Run Code Online (Sandbox Code Playgroud)

另外,有没有办法从长按手势中获取纬度/经度?

希望使其SwiftUI仅使用即可工作,而不包含UIKitUIViewRepresentable.

gesture mapkit swiftui

3
推荐指数
1
解决办法
855
查看次数

标签 统计

gesture ×1

mapkit ×1

swiftui ×1