Rumah > Soal Jawab > teks badan
Apabila memintas acara UIButton, saya tahu bahawa kaedah sendAction:to:forEvent:
akan dilaksanakan selepas butang diklik, jadi saya boleh mengaitkan kaedah ini untuk melakukan perkara lain, jadi kaedah manakah yang harus saya pintas untuk acara Ketik UIView?
过去多啦不再A梦2017-05-02 09:27:02
Acara ketik ditambah dengan kod berikut
self.backgroundTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleBackgroundTapGesture:)];
self.backgroundTapRecognizer.delegate = self;
[self.maskView addGestureRecognizer:self.backgroundTapRecognizer];
Anda boleh menggunakan shouldReceiveTouch untuk memintas
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isDescendantOfView:self.popupView]) { //判断条件,比如是popView
//NSLog(@"NO");
return NO; //点击无效
}
return YES;
}