zoukankan      html  css  js  c++  java
  • 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];

    }

  • 相关阅读:
    棋盘格渲染
    openvino踩坑之Data type is unsupported
    [video super resolution] ESPCN论文笔记
    tensorflow fp16训练
    openvino安装踩坑记
    python numpy中astype使用不当导致图像出现artifact
    Python~字典
    Django~待解决的问题
    正则表达式应用
    GitLab使用
  • 原文地址:https://www.cnblogs.com/guochaoboke/p/4730576.html
Copyright © 2011-2022 走看看