【问题标题】:single tap (hittest) does not fit with subviews单击(hittest)不适合子视图
【发布时间】:2013-11-01 01:20:14
【问题描述】:

更改 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);
}

【问题讨论】:

    标签: ios objective-c uigesturerecognizer subview hittest


    【解决方案1】:
    CGPoint touchPoint = [gestureRecognizer locationInView:myview]; // <-- not self.view
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-12
      • 2016-04-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多