0
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *firstTouch = [touches anyObject];
CGPoint firstPoint = [firstTouch locationInView:drawImage];
NSLog(@"drawimage retain coount touches began: %i",[drawImage retainCount]);
lastPointX = firstPoint.x;
lastPointY = firstPoint.y;
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [touches anyObject];
CGPoint movePoint = [touch locationInView:drawImage];
UIGraphicsBeginImageContext(drawImage.frame.size);
[drawImage.image drawInRect:drawImage.bounds];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), value);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), t1, t2, t3, 1);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPointX, lastPointY);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), movePoint.x, movePoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
lastPointX = movePoint.x;
lastPointY = movePoint.y;
NSLog(@"drawimage retain coount touches moved: %i",[drawImage retainCount]);
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint movePoint = [touch locationInView:drawImage];
UIGraphicsBeginImageContext(drawImage.frame.size);
[drawImage.image drawInRect:drawImage.bounds];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), value);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), t1, t2, t3, 1);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPointX, lastPointY);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), movePoint.x, movePoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"drawimage retain coount touches end: %i",[drawImage retainCount]);
}
這裏我得到的內存警告級別= 2。我怎樣才能刪除該警告?我如何刪除內存警告級別= 2
謝謝你的迴應,這裏drawImage佔用了大量的內存,當我釋放([drawImage release])這個在dealloc中,它沒有釋放,怎麼能釋放這個drawImage? –