làm cách nào tôi có thể hủy hoặc đặt lại số UIGestureRecognizer
? Vấn đề là, nếu tôi đặt waitForSomething
thành NO
trong một cử chỉ, sự kiện tiếp theo là UIGestureRecognizerStateChanged
. Nhưng sự kiện đầu tiên phải là UIGestureRecognizerStateBegan
.Cách huỷ/đặt lại UIGestureRecognizer
Mã của tôi:
- (void) panned:(UIPanGestureRecognizer *) recognizer {
if (waitForSomething) {
// cancel or reset the recognizer!
// because the next event should be UIGestureRecognizerStateBegan and not UIGestureRecognizerStateChanged
return;
}
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
// important initialisation code
break;
case UIGestureRecognizerStateChanged:
// do something
break;
}
}
Cám ơn các bạn giúp đỡ!
công trình như một say mê, nhờ – n13
Đây là một mẹo tuyệt vời, và thậm chí khuyến cáo của Apple trong một đoạn video WWDC gần đây –