最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - Get the point of user clicked on the MKMapView kotlin multiplatform - Stack Overflow

programmeradmin1浏览0评论

I have started a new project with KMM(Kotlin multiplatform). I need to use the original IOS map (MKMapView) in my project. According to the instructions of this article integrating-mapkit-in-compose-multiplatform-part-2 I was able to add all the things I needed to the program. But I have a problem, and that is that I cannot find any solution for get the user clicking point from the map. Is there anyone who has been able to do this? I also tried the UIGestureRecognizer or UITapGestureRecognizer event, but it didn't work.

class GestureDelegate :
    NSObject(),
    UIGestureRecognizerDelegateProtocol {
    override fun gestureRecognizer(
        gestureRecognizer: UIGestureRecognizer,
        shouldReceiveTouch: UITouch
    ): Boolean {
        println("Tap")
        return true
    }
}
UIKitView(
    modifier = Modifier.fillMaxSize(),
    factory = {
        mkMapView.apply {
            userInteractionEnabled = true
            val panGesture = UIGestureRecognizer(target = this, action = NSSelectorFromString("handleTap:"))
            panGesture.delegate = GestureDelegate()
            this.addGestureRecognizer(panGesture)
        }
    },
 }
发布评论

评论列表(0)

  1. 暂无评论