【发布时间】:2014-08-21 02:33:16
【问题描述】:
我正在尝试制作这个应用程序:
- 用户将手指放在要跟踪的屏幕上。
- 第二根手指在第一根手指周围画出第一根手指的轮廓。(本质上只是一个忽略第一根手指在屏幕上的绘图应用程序)
问题:
它创建的不是轮廓,而是星形。似乎正在绘制的线试图连接到两个接触点。
问题:
- 有没有办法忽略多点触控应用中的特定触控?
- 有没有办法在单点触控应用中取消第一次触控?
我的代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touchCount++;
NSLog(@"Touches Count: %i", touchCount);
if(touchCount >= 2)
{
drawingTouch = [touches anyObject];
CGPoint p = [drawingTouch locationInView:self];
[path moveToPoint:p];
drawingPoints = [[NSMutableArray alloc]init];
}
else
{
//???
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSArray *allTouches = [touches allObjects];
if(touchCount >= 2 && [allTouches count]>1)
{
UITouch *theTouch = allTouches[1];
CGPoint p = [theTouch locationInView:self];
[path addLineToPoint:p]; // (4)
[self setNeedsDisplay];
[drawingPoints addObject:[NSValue valueWithCGPoint:p]];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesMoved:touches withEvent:event];// This was copied from a tutorial but I will remove it and see what happens.
}
【问题讨论】:
-
你不应该自己打电话给
[self touchesMoved:touches withEvent:event]。
标签: objective-c drawing uibezierpath uitouch