problem when reusing "LazyTableImages"code
i try to reuse the "lazyTableimages" code but i got a problem that the first icons seen didn't get downloaded.I debug and I found that the connection doesn't get a response (only for these icons).
update this is the portion of the code which i think is the problem:
- (void)startDownload
{
self.activeDownload = [NSMutableData data];
NSURLConnection *conn = [[NSURLConnection a开发者_C百科lloc] initWithRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:appRecord.imageURLString]] delegate:self];
self.imageConnection = conn;
[conn release];
}
and I think that the connection doesn't have enough time to be established.
N.B:i use a custom myUITableViewCell.
I used the same code in some of my projects. I didn't find any problem in this code. May be you have missed out something else. Have you allocated the Object of IconDownloader ? and call the method startDownload.
Cheers, Raxit
Ok. That means you are having problem with below statement. Which is in cellForRowAtIndexPath method.
[self startIconDownload:appRecord forIndexPath:indexPath];
Am i right Dingua?
You have missed out something. you are calling [self startIconDownload:appRecord forIndexPath:indexPath]; from (void)loadImagesForOnscreenRows and cellForRowAtIndexPath method. Have you print the parameter in NSLog ? check the value of appRecord.imageURLString When you are calling it from cellForRowAtIndexPath.
The problem was that i call the method "[tableview reloadData]" from a thread (not the main thread) which will be canceled after that call,so for that reason the connection established to download icons was aborted(when it is called from "..cellForView.." method),so i changed the thread to an an "NSOperation" and i call on it the reloadData method on the main thread which will be like this "[tableView performSelectorOnMainThread:@selector(reloadData) WaitUntilFinshied:YES];
(syntax need to be verified)
精彩评论