Was dieser Fehler ist invalid context 0x0?
Schrieb ich den folgenden code in die ViewDidLoad -
//Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-(void)viewDidLoad {
[super viewDidLoad];
NSString *str = [NSString stringWithFormat:@"Veer"];
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
CGFloat values[4] = {55.0, 0.0, 0.0, 1.0};
CGColorRef glowColor = CGColorCreate(rgbColorspace, values);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShadowWithColor( context, CGSizeMake( 5.0, 0.0 ), 20.0f, glowColor);
[str drawAtPoint:CGPointMake(10.5f, 0.5f) withFont:[UIFont fontWithName:@"Helvetica" size:100.0f]];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60, 200, 250, 100)];
[label setBackgroundColor:[UIColor clearColor]];
label.font=[UIFont fontWithName:@"DBLCDTempBlack" size:50.0];
label.textColor = [UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:1.0];
[label setText:str];
[self.view addSubview:label];
}
In der Konsole sah ich, wie
Testing Clock[3286] <Error>: CGContextSetStyle: invalid context 0x0
Testing Clock[3286] <Error>: CGContextSetFont: invalid context 0x0
Testing Clock[3286] <Error>: CGContextSetTextMatrix: invalid context 0x0
Testing Clock[3286] <Error>: CGContextSetFontSize: invalid context 0x0
Testing Clock[3286] <Error>: CGContextSetTextPosition: invalid context 0x0
Testing Clock[3286] <Error>: CGContextShowGlyphsWithAdvances: invalid context 0x0
Kontext 0 X 0 bedeutet Objekt ist initialisiert, d.h. er ist null. in Ihrem Fall Kontext ist null.
aber was soll ich tun, um initialisiert?
CGContextRef context = UIGraphicsGetCurrentContext(); ich schrieb dies für Kontext
aber was soll ich tun, um initialisiert?
CGContextRef context = UIGraphicsGetCurrentContext(); ich schrieb dies für Kontext
InformationsquelleAutor Chatar Veer Suthar | 2011-07-06
Du musst angemeldet sein, um einen Kommentar abzugeben.
Sollten Sie, dass benutzerdefinierte Zeichnung code aus viewDidLoad und verschieben Sie es an drawRect.
Werden Sie auch brauchen, um eine Unterklasse der view-wenn Sie möchten, um Ihre eigenen drawRect-Methode.
Kasse diesem Beispiel: http://ykyuen.wordpress.com/2010/08/27/iphone-uiview-with-border/
Dieser code funktioniert nicht, wer hat upvote?
Habe ich schon erwähnt, dass ich tun möchte, in die gleiche Klasse, anderes wenn Sie das tun Betrieb jede Sekunde auf Objekte(benutzerdefinierte Klasse), dann wird es schwer werden,
InformationsquelleAutor Watson
Müssen Sie nur zu überprüfen, wenn Kontext vorhanden sein, bevor die Zeichnung :
InformationsquelleAutor anasaitali