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];

    }

  • 相关阅读:
    c 语言练习__去掉多余的空白字符_修正
    c 语言练习__求到N的阶乘的和。
    <<c 和指针 >> 部分笔记。
    AsciiDoc Markup Syntax Summary
    gdb 基本命令
    Ubuntu开启防火墙
    转载 jre精简
    windows 下指定jre运行java程序批处理指令
    虚拟机vmware的NAT网络
    liunx 端口权限
  • 原文地址:https://www.cnblogs.com/guochaoboke/p/4730576.html
Copyright © 2011-2022 走看看