2011-09-17 4 views
1

以下のコードが実行されたとき、私は、これらのエラーを得た:connectionDidFinishLoadingのUIGraphicsBeginImageContextを使用することはできますか?

[Switching to process 74682 thread 0x2003] 
[Switching to process 74682 thread 0x207] 
[Switching to process 74682 thread 0x720f] 

-

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
    UIImage = [[UIImage alloc] initWithData:self.resp_data; 
    CGSize itemSize = CGSizeMake(150); 
    UIGraphicsBeginImageContext(itemSize); 
    CGRect image_rect = CGRectMake(0.0,0.0,itemSize.width,itemSize.height); 
    [image drawInRect:image_rect]; 
    self.image_view.image = UIGraphicsGetImageFromCurrentImageContext(); // image_view ivar is connected to a UIImageView in the View associated to this controller 
    self.resp_data = nil; 
    self.imageConnection = nil; 
    [image release]; 

} 

問題とどのようにそれを解決するために何ができるか任意のアイデアを?助けるため(そしてもちろん、予想される画像は表示されません)

Thxを、

ステファン

答えて

2

テストされたコード:100%はそんなに、それはまた、私を助けて

#define kAppIconHeight 48 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
    // Set appIcon and clear temporary data/image 
    UIImage *image = [[UIImage alloc] initWithData:self.resp_data]; 

    if (image.size.width != kAppIconHeight && image.size.height != kAppIconHeight) 
    { 
     CGSize itemSize = CGSizeMake(kAppIconHeight, kAppIconHeight); 
     UIGraphicsBeginImageContext(itemSize); 
     CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height); 
     [image drawInRect:imageRect]; 
     self.image_view.image = UIGraphicsGetImageFromCurrentImageContext(); 
     UIGraphicsEndImageContext(); 
    } 
    else 
    { 
     self.image_view.image = image; 
    } 

    self.resp_data = nil; 
    [image release]; 

    // Release the connection now that it's finished 
    //self.imageConnection = nil; 

    // call our delegate and tell it that our icon is ready for display 
    //  [delegate appImageDidLoad:self.indexPathInTableView]; 
} 
+0

thaqワークスvij ..... –

+0

@Nag_iphoneようこそお友達。 http://chat.stackoverflow.com/rooms/682/conversation/do-u-want-instant-help-for-ur-question-or-ru-new-bee-to-iphone-ipad-develop –

+0

thaq soそれは私もvij ..... .....あなたが電話を知っているlangを知るのを助ける –

関連する問題