10
ürününün UIView
ürününün hazırlanmasına ilişkin bir sorunla karşılaşıyorum. Bazen (ama her zaman değil) hata mesajını görüyorum.<Error>: CGContextSaveGState: geçersiz bağlam 0x0 Hata
iPhone SDK 4.0 kullanıyorum. Kodum:
-(void)drawRect:(CGRect)rect
{
// Customized to draw some text
}
-(UIImage*) PrepareBackImage:(CGRect) aRect // aRect = (0,0,1800,1200)
{
UIImage* background;
background = [self GetImageFromView:self toRect:self.frame];
UIGraphicsBeginImageContext(aRect.size);
CGPoint backgroundPoint = CGPointMake(0,0);
[background drawAtPoint:backgroundPoint];
UIImage* backImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return backImage;
}
- (UIImage *) GetImageFromView:(UIView *)aView toRect:(CGRect)aRect
{
CGSize pageSize = aRect.size;
UIGraphicsBeginImageContext(pageSize);
[aView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Ayrıca sınıf izlemek için deneyin Bu, bu hatayı sunmakta ve bazı nesnelerin boyut veya çerçeveye sahip olup olmadığını görmektedir. –