저는 Stanford CS193p 과정을 연구 중이며 그래프를 그려보고 있습니다. 축 그리기는 작동하지만 그래프 자체를 그릴 수는 없습니다. 그 메시지를받습니다. 그리려 할 때 메시지가 나타납니다.문제 해결 drawingRect() 메서드의 CoreGraphics 선
CGContextAddLineToPoint: no current point.
그릴 때. 여기에 코드가 있습니다.
- (void)drawRect:(CGRect)rect
{
NSLog(@"Drawing Graph View");
CGPoint origin = CGPointMake(20, 350);
CGRect rect2 = CGRectMake(origin.x, origin.y, 250, -250);
[AxesDrawer drawAxesInRect:rect2 originAtPoint:origin scale:[self scale]];
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
CGContextSetLineWidth(context, 2);
[[UIColor redColor] setStroke];
CGContextMoveToPoint(context, origin.x, origin.y);
for (CGFloat i=0; i<250; i++) {
CGFloat yChange = [self.dataSource deltaY:self];
CGContextAddLineToPoint(context, origin.x+i, origin.y-yChange);
CGContextStrokePath(context);
}
UIGraphicsPopContext();
}
감사합니다. 완벽하게 작동했습니다. – MaxGabriel
그게 나를 위해 일한 .. –