I get images asynchronously with parse, and i insert them into an array with some other stuff.
I return this array to fill a tableView, and the rows has an UIImageView
, but some images that i get asynchronously doest get loaded when i fill the table with the array in cellForRowAtIndexPath
, so when i first look the tableView, i get the rows with an empty image in the cell, till i move the scroll in the tableView so cellForRowAtIndexPath
is called again and those images i was set in the array are already loaded.
I get the images also if i do a IBAction with [self.tableView reloadData];
i get the images.
The problem is that i return the cell inmediatelly and the image is not loaded. I'm using a custom TableViewCell. I found something about "AsyncImageView" to load the image, but i dont know how.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//Get the game for the row
GameModel *game = [self.currentMatches objectAtIndex:indexPath.row]; //HERE i load the images
MatchCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"GameCell" forIndexPath:indexPath];
cell.userImage.image = game.avatarp1; //I set the image to the cell but isnt loaded yet
//If i do this WORKS but i get 2 times the same image (on the game and now) (its a function that i created, that seems is calling tableView or so when assigns the image to the cell, i dont understand why it works
[ParseModel getAvatarWithUser:game.p1 completionBlock:^(UIImage *avatar) {
cell.userImage.image = avatar;
}];