目标C:触摸点距离
问题描述:
我遇到了我正在绘制的应用程序的问题。目标C:触摸点距离
在肖像其接触点是好的,该行遵循正确的接触点,但是当我的方向切换到横向这里发生了什么事:
红色的X标志是触摸点,但线在不同的点开始。
我要怎么解决这个问题?
这里是我的代码:
在viewDidLoad中:
touchView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bgimg.png"]];
[touchView setFrame:CGRectMake(0, 0, 768, 1024)];
[self.view addSubview:touchView];
[self.view sendSubviewToBack:touchView];
touchMoved = 0;
touchView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
上touchesMoved:
UIGraphicsBeginImageContext(self.view.frame.size);
[touchView.image drawInRect:CGRectMake(0, 0, 768, 1024)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 25.0f);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0, 0, 0, 1);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), endingPoint.x, endingPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentTouch.x, currentTouch.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
touchView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
答
请告诉我认为heirachy样的?
如果触摸位于不同视图或父视图中,您最需要调用UIView的convertPoint:方法来获取点的正确位置。
如果你可以发表你的看法微弱继承人我也许能帮助更多的
干杯,
迈克尔
是的,这是从不同的UIImageView ... – Cristiano