Hier ist der Code, den ich zu zeichnen verwenden:Warum gibt es einen ungültigen Kontextfehler?
- (void) drawSomething
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);
CGContextSetLineWidth(context, 6.0);
CGContextMoveToPoint(context, 100.0f, 100.0f);
CGContextAddLineToPoint(context, 200.0f, 200.0f);
CGContextStrokePath(context);
NSLog(@"draw");
}
Aber ich habe den Fehler wie folgt aus:
[Session started at 2010-04-03 17:51:07 +0800.]
Sat Apr 3 17:51:09 MacBook.local MyApp[12869] <Error>: CGContextSetRGBStrokeColor: invalid context
Sat Apr 3 17:51:09 MacBook.local MyApp[12869] <Error>: CGContextSetLineWidth: invalid context
Sat Apr 3 17:51:09 MacBook.local MyApp[12869] <Error>: CGContextMoveToPoint: invalid context
Sat Apr 3 17:51:09 MacBook.local MyApp[12869] <Error>: CGContextAddLineToPoint: invalid context
Sat Apr 3 17:51:09 MacBook.local MyApp[12869] <Error>: CGContextDrawPath: invalid context
Warum es mich aufgefordert, zu sagen, dass der Kontext zum Invaliden wird?
Von was rufen Sie drawSomething ab? Was sollte der aktuelle Kontext dann sein? –
es von meiner init-Methode aufgerufen. aktueller Kontext ist nicht die aktuelle Ansicht? – Tattat