次のように、NSURLConnectionを使用してHTTP経由で画像を取得しています-
NSMutableData *receivedData;
- (void)getImage {
self.receivedData = [[NSMutableData alloc] init];
NSURLConnection *theConnection = // create connection
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
UIImage *theImage = [UIImage imageWithData:receivedData];
}
通常は問題なく動作しますが、ログに記録されることがあります-:破損したJPEGデータ:データセグメントの途中で終了します
この時点では、画像は完全にはレンダリングされません。おそらく75%が表示され、右下隅が灰色のボックスになります。
これを修正する方法について何かアイデアはありますか?画像を正しく作成していませんか?