0

更改 uiview 位置(y = -50)后,单击不适合我添加的子视图的位置。Hittest 表示 touchview 从 -50 开始,而不是 0。如何解决这个问题?

myview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, -50, mywidth, myheight)];

单击:

// SINGLE TAP
- (void)singleTapRecognized:(UIGestureRecognizer *)gestureRecognizer {

    CGPoint touchPoint = [gestureRecognizer locationInView:self.view];
    UIView *touchView = [myview hitTest:touchPoint withEvent:nil];

    NSLog(@"Y touchPoint: %f",touchPoint.y);
    NSLog(@"Y touchView: %f",touchView.frame.origin.y);
}
4

1 回答 1

0
CGPoint touchPoint = [gestureRecognizer locationInView:myview]; // <-- not self.view

在我看来,一切都发生了。:-)

于 2013-11-01T12:41:14.137 回答