手势触碰点击

有时候下面方法无效:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

   [self.view endEditing:YES];

 

}

 

只好手动添加手势触碰点击:

@property (strong) UITapGestureRecognizer *sideslipTapGes;

@property (nonatomic, strong) UIView *touchView;

 //单击覆盖层手势

    _sideslipTapGes= [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handeTap)];

    [_sideslipTapGes setNumberOfTapsRequired:1];

    

    [_touchView addGestureRecognizer:_sideslipTapGes];

 

 

- (void)handeTap {

  

    [self.view endEditing:YES];

}

posted @ 2015-06-13 17:23  穿山甲随笔-iOS开发  阅读(250)  评论(0编辑  收藏  举报