zoukankan      html  css  js  c++  java
  • iOS UIButton单双击处理响应不同的方法

      //显示目标 双击显示当前用户坐标位置
       UIButton * btnShowDistination = [[UIButton alloc]initWithFrame:CGRectMake(15, SCREEN_HEIGHT-110-64, 35, 35)];
        [btnShowDistination setBackgroundImage:[UIImage imageNamed:@"show_distination"] forState:UIControlStateNormal];
        [btnShowDistination addTarget:self action:@selector(btnTouchOne:forEvent:) forControlEvents:UIControlEventTouchDown];
        
        [btnShowDistination addTarget:self action:@selector(buttonRepeatAction:) forControlEvents:UIControlEventTouchDownRepeat];
    
        [self.view addSubview:btnShowDistination];
    
        
    
    }
    
    - (void)btnTouchOne:(UIButton *)sender forEvent:(UIEvent *)event
    {
        [self performSelector:@selector(showDistination:) withObject:sender afterDelay:0.3];
    }
    
    - (void)buttonRepeatAction:(UIButton *)sender{
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showDistination:) object:sender];
        [self showsUserLocation:sender];
    }
    
    - (void)showsUserLocation:(UIButton *)sender
    {
        if (_mapView.userLocation) {
            [_mapView setCenterCoordinate:_mapView.userLocation.coordinate animated:YES];
            _mapView.zoomLevel = 17;
        }
    }
    
    - (void)showDistination:(UIButton *)sender{
        
        if (_circle) {
        [_mapView setCenterCoordinate:_circle.coordinate animated:NO];
            _mapView.zoomLevel = 17;
        }
        
    }
  • 相关阅读:
    Apache Pig的前世今生
    openssl之EVP系列之6---EVP_Encrypt系列函数编程架构及样例
    P3388 【模板】割点(割顶)
    让priority_queue支持小根堆的几种方法
    2017.11.7解题报告
    一个例子教你如何与出题人斗智斗勇
    debug
    树上倍增求LCA及例题
    素数的筛法
    Catalan卡特兰数入门
  • 原文地址:https://www.cnblogs.com/zhujin/p/5584899.html
Copyright © 2011-2022 走看看