UITapGestureRecognizer - PullRequest
       2

UITapGestureRecognizer

0 голосов
/ 14 октября 2010

Как узнать местоположение с помощью

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
}

метод?

Ответы [ 2 ]

0 голосов
/ 17 июня 2016

Вот пример.

-(void)handleGesture:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint p = [gestureRecognizer locationInView:self.navigationController.toolbar];
CGRect nextButtonRect = CGRectMake(self.navigationController.toolbar.frame.size.width * 2 / 3,
                                   0,
                                   self.navigationController.toolbar.frame.size.width / 3,
                                   self.navigationController.toolbar.frame.size.height);

CGRect previousButtonRect = CGRectMake(0,
                                   0,
                                   self.navigationController.toolbar.frame.size.width / 3,
                                   self.navigationController.toolbar.frame.size.height);

if (CGRectContainsPoint(previousButtonRect, p))
    [self tapOnPreviousNews];

if (CGRectContainsPoint(nextButtonRect, p))
    [self tapOnNextNews];
}
0 голосов
/ 15 марта 2011

распознаватель жестов имеет locationInView: метод просмотра.также UIGestureRecognizer имеет свойство .view, так что вы можете использовать это.

...