gpt4 book ai didi

iPhone map 套件 : select location (coordinates) manually by touching MKMapView

转载 作者:行者123 更新时间:2023-12-03 18:50:36 29 4
gpt4 key购买 nike

我想为用户提供(手动)选择纬度的可能性。又长。通过触摸 MKMapView 进行坐标。我怎样才能实现这一目标?

我已经看到 MKMapView 委托(delegate)提供了方法 convertPoint:toCooperativeFromView: 。我认为,这可能是一个好的开始,但我不知道如何通过触摸操作创建一个点。

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

最佳答案

vwMapMKMapview对象的名称:

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(foundTap:)]; 
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.numberOfTouchesRequired = 1;
[vwMap addGestureRecognizer:tapRecognizer];



-(IBAction)foundTap:(UITapGestureRecognizer *)recognizer {
CGPoint point = [recognizer locationInView:vwMap];
CLLocationCoordinate2D tapPoint = [vwMap convertPoint:point toCoordinateFromView:vwMap];

MKPointAnnotation *point1 = [[MKPointAnnotation alloc] init];
point1.coordinate = tapPoint;

[vwMap addAnnotation:point1];
}

关于iPhone map 套件 : select location (coordinates) manually by touching MKMapView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3451705/

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