有时候下面方法无效:
-(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];
}