我正在创建UIControl
的子类,并添加到我的视图控制器的视图
- (BOOL) beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;
- (BOOL) continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;
- (void) endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;
当我触摸和跟踪视图内部时,continueTrackingWithTouch
被连续调用,但是即使我在跟踪...
预先感谢...
我知道这是旧的,但是我遇到了同样的问题,请检查您的一个超级浏览器是否具有手势识别者,并在需要用户使用Uicontrol时停用它们。
我实际上结束了,改变了Uicontrol的监督,以避免这种冲突。
Try This the below code is for signature feature this will help you to see how to track touch continuously
CGPoint lastPoint;
BOOL mouseSwiped;
int mouseMoved;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = NO;
/* The below statements will help to get the exact point user touches with out this it will take ZERO yaxis */
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:signatureImageView]; // replace signatureImageView with your view
lastPoint.y -= 20;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:signatureImageView];// replace signatureImageView with your view
currentPoint.y -= 20;
UIGraphicsBeginImageContext(signatureImageView.frame.size);
[signatureImageView.image drawInRect:CGRectMake(0, 0, signatureImageView.frame.size.width, signatureImageView.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapButt);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 1.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
signatureImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
mouseMoved++;
if (mouseMoved == 20) {
mouseMoved = 0;
}
}