一个奇怪的问题。我想从网上加载一张图片,所以我使用 NSURLConnection 来做。当我在 ios4.3 上测试我的代码时,一切正常。但是当我在 ios5.0 上启动我的应用程序时,我发现连接:didreceiveData 不管我做什么都没有被调用。otherelse函数调用正常,就像ios4.3的connectionDidFinishLoading和ios5.0的connectionDidFinishDownloading一样。所以你们,谁能帮助我,谢谢先进!
-(void)load
{
if(isDownloading){
return;
}
if(conn != nil){
[conn release];
}
if(data != nil){
[data release];
data = nil;
}
[self isDownloading:YES];
ImageDownloadData* imageDownloadData = [imageList objectAtIndex:count];
NSURL* url = [imageDownloadData url];
NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(conn){
[conn start];
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)rd
{
NSLog(@"data");
if(!data){
data = [[NSMutableData alloc] initWithData:rd];
return;
}
[data appendData:rd];
}