我使用过此代码
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.DrawingImage];
UIGraphicsBeginImageContext(self.DrawingImage.frame.size);
[DrawingImage.image drawInRect:CGRectMake(0, 0, DrawingImage.frame.size.width, DrawingImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 1);
CGContextRef cgref = UIGraphicsGetCurrentContext();
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
self.DrawingImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
使用imageView创建绘图应用。唯一的区别是我的drawingImageView没有添加为subView,我已经声明为IBOutlet。
我的问题是,在iOS模拟器上,应用程序运行完美,但在真实设备上,使用iOS 7,直到我没有停止我的手指(在touchMoved事件,而不是在touchEnd)我看不到路线我的手指,ImageView保持空白!
有人遇到过同样的问题吗?或者有人可以帮我用不同的代码做同样的事情?
谢谢大家,对不起我的英语