【发布时间】:2010-11-07 02:05:00
【问题描述】:
我通过 HTTP 获取图像,使用 NSURLConnection,如下 -
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%,然后右下角是一个灰色框。
关于如何解决此问题的任何想法?我是不是在不正确地构建我的图像?
【问题讨论】:
-
我已经下载了很多图片,还没有看到这个。你的图像非常大吗?这是否发生在其他设备(计算机、模拟器)上?
-
不是特别大,不是。我确实在 iPhone 和模拟器上都看到了它(但不是通过网络浏览器点击图像)。
-
请同时检查您的互联网连接。
标签: iphone cocoa-touch uiimage