更改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);
}
答案 0 :(得分:0)
CGPoint touchPoint = [gestureRecognizer locationInView:myview]; // <-- not self.view
一切都发生在我的观点中。 : - )