Can't do fast enough to keep up with touch?

I am trying to implement simple drawing functions in my application for iPhone. I tried updating the bitmap with a raster brush, and I also tried this tutorial .

Both methods have the same problem, although the code is almost completely different. This only happens on the device - the simulator works great.

When I touch the screen and move my finger, the screen does not refresh. When I pause or raise my finger, the screen refreshes. This is not a good user interface!

I tried calling drawRect from touchhesMoved directly, but found that the drawing context (which I retrieve using the UIGraphicsGetCurrentContext) is invalid for many calls, so painting the screen for every touch of Loved itself does not work.

Any ideas?

Thanks for any help, it was very unpleasant!

Henning

+5
source share
2 answers

It seems to me that you are not letting the main startup cycle refresh the display. Your drawing code may take longer than the time between touch events, so the display never refreshes. When you lift your finger, it performs an update because it is no longer burdened with your drawing.

, (, ), - NSOperationQueue , .

performSelector: withObject: afterDelay 10 ( ). . , , .

+2

drawRect:. , [self setNeedsDisplay] touchesMoved, drawRect:.

0

All Articles