Note that there are some explanatory texts on larger screens.

plurals
  1. POLag while drawing in ios7
    text
    copied!<p>I am having an app in which I am doing some sketching on a view. </p> <p>So far, it was working fine until I installed <code>ios7</code>. </p> <p>My app uses touches moved method for recognizing the change of a movement. But when I draw a line, touches method gets called but line doesn't get updated until I touch ends in <code>ios7</code>.</p> <p>So there is a slight lag in drawing. </p> <p>It works fine on <code>ios6</code> and on <code>ios7</code> simulator but when i test it on a real <code>ios7</code> device, there is a lag in drawing algorithm.</p> <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (!isImageSelection) { mouseSwiped = NO; UITouch *touch = [touches anyObject]; if ( [touch view] != baseview) { lastPoint2 = [touch locationInView:self.viewDrawing2]; } } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (!isImageSelection) { // NSLog(@"in image selection==%d touch moved ",isImageSelection ); mouseSwiped = YES; UITouch *touch = [touches anyObject]; // if (([touch view] != btnInkColor) || ([touch view] != btnPenSize) || ([touch view] != baseview)) { if ( [touch view] != baseview) { CGPoint currentPoint = [touch locationInView:self.viewDrawing]; if(isEraser) { // [[NSUserDefaults standardUserDefaults] floatForKey:@"strokeValue"]; UIGraphicsBeginImageContext(self.viewDrawing.frame.size); [imgDrawing.image drawInRect:CGRectMake(0, 0, self.viewDrawing.frame.size.width, self.viewDrawing.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), stroke); //uncommented by prerak CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); imgDrawing.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } else { float strokeT= [[NSUserDefaults standardUserDefaults] floatForKey:@"strokeValue"]; // NSLog(@"strokeT=%f",strokeT); UIGraphicsBeginImageContext(self.viewDrawing.frame.size); [imgDrawing.image drawInRect:CGRectMake(0, 0, self.viewDrawing.frame.size.width, self.viewDrawing.frame.size.height)]; // NSLog(@"STROKE %f",stroke); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), strokeT); CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy); float redT=[[NSUserDefaults standardUserDefaults] floatForKey:@"redvalue"]; float greenT= [[NSUserDefaults standardUserDefaults] floatForKey:@"greenvalue"]; float blueT= [[NSUserDefaults standardUserDefaults] floatForKey:@"bluevalue"]; // NSLog(@"red=%f",redT); // NSLog(@"green=%f",greenT); // NSLog(@"blue=%f",blueT); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), redT, greenT, blueT, 1.0); CGContextSetRGBFillColor(UIGraphicsGetCurrentContext(), redT, greenT, blueT, 1.0); CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); imgDrawing.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } lastPoint = currentPoint; } } } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //if (([touch view] != btnInkColor) || ([touch view] != btnPenSize) || ([touch view] != baseview)) { if ( [touch view] != baseview) { if (!isImageSelection) { if(!mouseSwiped) { if (isEraser) { UIGraphicsBeginImageContext(self.viewDrawing.frame.size); [imgDrawing.image drawInRect:CGRectMake(0, 0, self.viewDrawing.frame.size.width, self.viewDrawing.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), stroke); // CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); CGContextFlush(UIGraphicsGetCurrentContext()); imgDrawing.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } else { UIGraphicsBeginImageContext(self.viewDrawing.frame.size); [imgDrawing.image drawInRect:CGRectMake(0, 0, self.viewDrawing.frame.size.width, self.viewDrawing.frame.size.height)]; CGContextSetLineWidth(UIGraphicsGetCurrentContext(), stroke); CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); CGContextSetRGBFillColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); CGContextFlush(UIGraphicsGetCurrentContext()); imgDrawing.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } } } } } } </code></pre> <p>How can i solve this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload