I am using SDWwbImage, wich i download from here:
I tested in the method: cellForRowAtIndexPath
and everything works fine, here is my code:
[cell.image setImageWithURL:[NSURL URLWithString:object.imageUrl]];
Now i need to call an image outside this method (eg: heightForRowAtIndexPath
, viewDidLoad
), and i always get no image, here is my code:
UIImageView *test = [[UIImageView alloc] init];
[test setImageWithURL:[NSURL URLWithString:categories.imageUrl]];
NSLog(@"height: %f", test.image.size.height);
Is it disallowed to use setImageWithURL
anywhere? how can i solve this?
EDITED
I tried to add the completion block to know when the download is finished and refresh the uitablevew, here is my code:
UIImageView *test = [[UIImageView alloc] init];
[test setImageWithURL:[NSURL URLWithString:object.imageUrl]
placeholderImage:[UIImage imageNamed:@"ic_launcher_57@2x.png"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
counterY++;
if (counterY == counterX) {
NSLog(@"reloading");
[self.tableView reloadData];
}
}];
But only the first time the controller is loaded, this doesnt work. Every time after this everything is fine.It looks like something cancel de download the first time.