小编Par*_*dhu的帖子

CGContextAddLineToPoint:没有当前点

我正在开发一个模式锁定应用程序(如Android锁定).

我想在点之间画线来打开锁,但是当我画画时,它会返回一个错误:

<Error>: CGContextAddLineToPoint: no current point

它在iOS 5.0和之前的工作正常但它在5.1中显示错误.

这是我的代码:

 - (void)drawRect:(CGRect)rect
{
 NSLog(@"drawrect...%@",NSStringFromCGRect(rect));

 if (!self._trackPointValue)
 return;

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 10.0);
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[] = {0.5, 1.0, 0.5, 0.8};
CGColorRef color = CGColorCreate(colorspace, components);
CGContextSetStrokeColorWithColor(context, color);

CGPoint from;
UIView *lastDot;
for (UIView *dotView in self._dotViews) {  //_dotViews array of points
 from = dotView.center;      
 if (!lastDot)
 {
  CGContextMoveToPoint(context, from.x, from.y);

  }
 else
 {
    NSLog(@"from : %@",NSStringFromCGPoint(from));
   CGContextAddLineToPoint(context, from.x, from.y);

 }

 lastDot = dotView;
}

 CGPoint pt …
Run Code Online (Sandbox Code Playgroud)

iphone xcode xcode4 ios5 xcode4.2

9
推荐指数
2
解决办法
8234
查看次数

标签 统计

ios5 ×1

iphone ×1

xcode ×1

xcode4 ×1

xcode4.2 ×1