码迷,mamicode.com
首页 > 其他好文 > 详细

UITapGestureRecognizer

时间:2014-09-22 23:43:03      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   div   sp   cti   on   c   

Configuring the Gesture

@property(nonatomic) NSUInteger numberOfTapsRequired
@property(nonatomic) NSUInteger numberOfTouchesRequired

 

例子

    // 单击的 Recognizer
    UITapGestureRecognizer* singleRecognizer;
    singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(SingleTap:)];
    //点击的次数
    singleRecognizer.numberOfTapsRequired = 1; // 单击
    [self.view addGestureRecognizer:singleRecognizer];
    
    // 双击的 Recognizer
    UITapGestureRecognizer* doubleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(DoubleTap:)];
    doubleRecognizer.numberOfTapsRequired = 2; // 双击
    //关键语句,给self.view添加一个手势监测;
    [self.view addGestureRecognizer:doubleRecognizer];
    
    // 关键在这一行,双击手势确定监测失败才会触发单击手势的相应操作
    [singleRecognizer requireGestureRecognizerToFail:doubleRecognizer];
    [singleRecognizer release];
    [doubleRecognizer release];

 

 

 



UITapGestureRecognizer

标签:style   blog   io   ar   div   sp   cti   on   c   

原文地址:http://www.cnblogs.com/zhongriqianqian/p/3986664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!