星空网 > 软件开发 > 操作系统

iOS 触摸的位置放一个大头针

iOS 触摸的位置放一个大头针

UITapGestureRecognizer *mTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapPress:)];  
    [self.mapView addGestureRecognizer:mTap];  

事件实现如下:
[cpp] view plaincopyprint?
- (void)tapPress:(UIGestureRecognizer*)gestureRecognizer {  
      
   

 

    CGPoint touchPoint = [gestureRecognizer locationInView:_mapView];//这里touchPoint是点击的某点在地图控件中的位置

    CLLocationCoordinate2D touchMapCoordinate =

    [_mapView convertPoint:touchPoint toCoordinateFromView:_mapView];//这里touchMapCoordinate就是该点的经纬度了

    

    NSLog(@"touching %f,%f",touchMapCoordinate.latitude,touchMapCoordinate.longitude);

    

        CLLocationCoordinate2D location=CLLocationCoordinate2DMake(touchMapCoordinate.latitude, touchMapCoordinate.longitude);

        KCAnnotation *annotation=[[KCAnnotation alloc]init];

        annotation.title=@"Kenshin&Kaoru";

        annotation.subtitle=@"Kenshin Cui's Home";

        annotation.coordinate=location;

        annotation.image=[UIImage imageNamed:@"icon_paopao_waterdrop_streetscape.png"];

        annotation.icon=[UIImage imageNamed:@"icon_mark2.png"];

        annotation.detail=@"Kenshin Cui...";

        annotation2.rate=[UIImage imageNamed:@"icon_Movie_Star_rating.png"];

        [_mapView addAnnotation:annotation2];

}




原标题:iOS 触摸的位置放一个大头针

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

亚马逊卖家注意!prime day这些一定要提前准备好!:https://www.kjdsnews.com/a/1446251.html
阿里Q4财报:菜鸟第四财季营收136.19亿元,同比增长18%:https://www.kjdsnews.com/a/1447211.html
独家丨SHEIN最快于本月卷土重来进入印度市场:https://www.kjdsnews.com/a/1447212.html
出口斐济注意事项:https://www.kjdsnews.com/a/1447213.html
什么是抖音本地生活服务?:https://www.kjdsnews.com/a/1447214.html
美国《消费者告知法案》实行将给跨境电商卖家带来哪些隐形风险?:https://www.kjdsnews.com/a/1447215.html
德国有那些品牌公司:https://www.vstour.cn/a/408236.html
黔南瓮安AAA以上旅游景点 黔南瓮安aaa以上旅游景点:https://www.vstour.cn/a/408237.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流