2011-07-27 104 views
1

每當我在模擬器或iPhone上運行我的應用程序時,控制檯都顯示以下語句。 它實際上想說什麼?
控制檯中的錯誤消息

** *試圖彈出一個未知的自動釋放池(0x6830200)
<錯誤>:CGContextScaleCTM:無效的情況下爲0x0
<錯誤>:CGContextTranslateCTM:無效的情況下爲0x0
<錯誤>:CGContextConcatCTM:無效的上下文爲0x0
< 錯誤>:CGContextDrawImage:無效的上下文爲0x0
< 錯誤>:CGContextScaleCTM:無效的上下文爲0x0
<錯誤>:CGContextTranslateCTM:無效的上下文爲0x0
<錯誤>:CGContextConcatCTM:無效的上下文爲0x0
<錯誤>:CGContextDrawImage:無效的上下文爲0x0
<錯誤>:CGContextScaleCTM:無效的上下文爲0x0
<錯誤>:CGContextTranslateCTM:無效的上下文爲0x0
< 錯誤>:CGContextConcatCTM:無效的上下文爲0x0
< 錯誤>:CGContextTranslateCTM:無效的上下文爲0x0
< 錯誤>:CGContextConcatCTM:無效的上下文爲0x0
<錯誤>:CGContextDrawImage:無效的情況下爲0x0

如何解決呢?

以下爲其中imgPic是UIImage的實例的引用代碼...

int kMaxResolution = 640; 
    CGImageRef imgRef = imgPic.CGImage; 
    CGFloat width = CGImageGetWidth(imgRef);  
    CGFloat height = CGImageGetHeight(imgRef); 
    CGAffineTransform transform = CGAffineTransformIdentity;  
    CGRect bounds = CGRectMake(0, 0, width, height); 
    if (width > kMaxResolution || height > kMaxResolution) 
    {  
     CGFloat ratio = width/height;  
     if (ratio > 1) 
     {   
      bounds.size.width = kMaxResolution;   
      bounds.size.height = roundf(bounds.size.width/ratio);   
     }  
     else 
     { 
      bounds.size.height = kMaxResolution;    
      bounds.size.width = roundf(bounds.size.height * ratio);   
     }  
    } 
    CGFloat scaleRatio = bounds.size.width/width; 
    CGSize imageSize = CGSizeMake(CGImageGetWidth(imgRef), CGImageGetHeight(imgRef)); 
    CGFloat boundHeight;  

    UIGraphicsBeginImageContext(bounds.size); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextScaleCTM(context, scaleRatio, -scaleRatio);   
    CGContextTranslateCTM(context, 0, -height);  

    CGContextConcatCTM(context, transform); 
    CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height), imgRef); 
    UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
+0

我有這個...我修好了,但我實在不記得如何。你在做自定義繪圖嗎?如果是這樣,你可以發佈代碼嗎? –

+0

我想從Web服務加載異步圖像下載。 –

+0

你能發佈你的下載這個圖片的實際代碼嗎? –

回答

1

我認爲他試圖告訴你,你的情況下是無效的。 :)

+0

有沒有什麼適當的方法可以找出確切的問題在哪裏出現? –

+0

您的環境是否有效?你有沒有檢查它是否爲空? –