我的应用程序出现内存警告,然后它崩溃了。这个错误,我认为是在我的触摸绘图功能上,因为当我尝试使用 alloc 工具运行它时,当我继续在屏幕上移动手指时,内存开始增加。
这是我的代码。
touchSwiped = YES;
UITouch *touch = [touches anyObject];
previousPoint2 = previousPoint1;
previousPoint1 = currentTouch;
currentTouch = [touch locationInView:self.view];
CGPoint mid1 = midPoint(previousPoint2, previousPoint1);
CGPoint mid2 = midPoint(currentTouch, previousPoint1);
UIGraphicsBeginImageContext(CGSizeMake(480 , 320));
[drawView.image drawInRect:CGRectMake(0, 0, 480,320)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineCap(context,kCGLineCapRound);
CGContextSetLineWidth(context, inkWidth);
CGContextSetBlendMode(context, blendMode);
CGContextSetRGBStrokeColor(context,redColor, greenColor, blueColor, 1);
CGContextBeginPath(context);
CGContextMoveToPoint(context, mid1.x, mid1.y);
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGContextStrokePath(context);
drawView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsGetCurrentContext();