首页 > 移动平台 > 详细

iOS UIButton单双击处理响应不同的方法

时间:2016-06-14 19:03:46      阅读:169      评论:0      收藏:0      [点我收藏+]
  //显示目标 双击显示当前用户坐标位置
   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;
    }
    
}

 

iOS UIButton单双击处理响应不同的方法

原文:http://www.cnblogs.com/zhujin/p/5584899.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!