mercredi 29 octobre 2014

UIPanGestureRecognizer - determine if stop location is inside CGRect


Vote count:

0




This one is driving me batty. I want to capture the stop location of a UIPanGestureRecognizer swipe. Then, I need to see if this point lies within a UITableView. Seems pretty simple, but I can't make it work. Regardless of what I swipe, this function always determines that I stopped somewhere inside the UITableView, even when I clearly am not. Anyone see what I am doing wrong? Thanks`!



- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
CGPoint stopLocation = [recognizer locationInView:self.view];

// if the user swipes from within the uitable, disregard it
// using the stopLocation because it is more accurate
CGRect frame = self.tableView.frame;
NSLog(@"%f %f %f %f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);

if (CGRectContainsPoint(frame, stopLocation)) {
NSLog(@"inside table");
NSLog(@"%f %f", stopLocation.x, stopLocation.y);
return;
}
}


asked 1 min ago

usr55410

1,748






UIPanGestureRecognizer - determine if stop location is inside CGRect

Aucun commentaire:

Enregistrer un commentaire