M
M
ManWithBear2014-04-25 02:13:47
Objective-C
ManWithBear, 2014-04-25 02:13:47

How to increase UITouch reviews?

How can I increase the number of calls
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
per unit of time?
I am writing a drawing application, drawing occurs during the call of this function, as a result of which everything is fine with a slow movement of the finger, but with fast movements, gaps are obtained.
It is not possible to connect the dots with each other, since it is not the drawing itself that is going on, but the restoration of the image (copying sections of the image).
Update
When pressed and moved, this function is called:

- (void)eraseInPoint:(CGPoint)point {
    float x = point.x-brushSize/2, y = point.y-brushSize/2;
    float width = brushSize, height = brushSize;
    CGRect dirtyRect = CGRectMake(x, y, width, height);
    CGRect drawRect = dirtyRect;
    drawRect.origin.y = self.bounds.size.height-drawRect.origin.y-drawRect.size.height;
    CGImageRef erase = CGImageCreateWithImageInRect(startedImage, drawRect);
    CGContextDrawImage(cacheContext, dirtyRect, erase);
    CGImageRelease(erase);
    [self setNeedsDisplayInRect:dirtyRect];
}

startedImage - original image before changes
cacheContext - drawing context

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2014-04-25
@ManWithBear

Most likely you are trying to "draw" in the touchesMoved method, which eats up resources and the program starts to stumble. try removing the drawing code and see if the method call becomes more frequent. if so, then in the touchesMoved method you simply remember the coordinates, and in parallel, by tayier (or in some other way), start redrawing the screen, choosing the frequency empirically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question