我使用parse异步获取图像,并将其插入与其他某些东西的数组中。我回来这个数组来填充tableView,并且行有一个UIImageView
,但一些图像,我异步doest得到加载时,我填充表中的数组cellForRowAtIndexPath
,所以当我第一次看tableView,我获取单元格中的空图像的行,直到我移动tableView中的滚动,所以cellForRowAtIndexPath
再次被调用,并且我在数组中设置的图像已经加载。当图像异步加载时更新tableView
我得到的图像也如果我做一个IBAction与[self.tableView reloadData];
我得到的图像。
问题是,我立即返回单元格,图像未加载。 我正在使用自定义TableViewCell。 我发现了一些关于"AsyncImageView"来加载图像,但我不知道如何。
- (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;
}];
只是这样做[yourtableView reloadData]; –