Я изо всех сил пытаюсь получить поведение, которое я хотел бы получить от распознавателей жестов, в частности, отмену определенных жестов, если другие уволили.
У меня есть scrollView набор для пейджинга и несколько subviews на каждой странице. Я добавил распознавателя жестов касания, чтобы перейти к следующей или предыдущей странице, если пользователь вступает вправо или влево от страницы.
// Add a gesture recogniser turn pages on a single tap at the edge of a page
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];
tapGesture.cancelsTouchesInView = NO;
[self addGestureRecognizer:tapGesture];
[tapGesture release];
и мой обработчик жестов:
- (void) tapGestureHandler:(UIGestureRecognizer *) gestureRecognizer {
const CGFloat kTapMargin = 180;
// Get the position of the point tapped in the window co-ordinate system
CGPoint tapPoint = [gestureRecognizer locationInView:nil];
// If the tap point is to the left of the page then go back a page
if (tapPoint.x > (self.frame.size.width - kTapMargin)) [self scrollRectToVisible:pageViewRightFrame animated:YES];
// If the tap point is to the right of the page then go forward a page
else if (tapPoint.x < kTapMargin) [self scrollRectToVisible:pageViewLeftFrame animated:YES];
}
Все работает хорошо, за исключением случаев, когда у меня есть subview на странице, в которой есть кнопки. Я хочу, чтобы иметь возможность игнорировать кран, чтобы перевернуть страницу, если пользователь коснулся кнопки в subView, и я не могу понять, как это сделать.
Приветствия
Dave