2010-12-22 18 views
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; 
} 

cevap

4

Hata <Error>: CGContextSaveGState: invalid context 0x0 demektir ya da CGContext NULL veya, Bağlam büyüklüğü boş olduğunu sizin durumunuzda daha makul bir açıklaması, (CGSizeZero)

+0

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. –

İlgili konular