我在 Parse.com 上有一个表格,可以让我存储事件信息。图片、标题、日期和描述。我正在尝试获取图像并将其分配给我开发的自定义单元格中的 UIImageView ......数据加载正常,自定义单元格工作,但图像永远不会更新......我的逻辑代码似乎合法,但话又说回来,我是新人......所以任何帮助表示赞赏。
有问题的代码就在我有评论“//---事件图像”之后
我只是想弄清楚为什么我的图像没有更新。
谢谢!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *simpleTableIdentifier = @"eventCell";
VFTEventCell *cell = (VFTEventCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"EventTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
//--- Event Title
cell.title.text = [object objectForKey:@"title"];
//--- Event Date
NSDate *eventDate = [object objectForKey:@"date"];
if(eventDate != NULL)
{
NSDate *date = [object objectForKey:@"date"];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy"];
NSString *dateString = [dateFormatter stringFromDate:date];
cell.date.text = dateString;
}
//--- Event Image
PFFile *eventImage = [object objectForKey:@"image"];
if(eventImage != NULL)
{
[eventImage getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
UIImage *thumbnailImage = [UIImage imageWithData:imageData];
UIImageView *thumbnailImageView = [[UIImageView alloc] initWithImage:thumbnailImage];
cell.image = thumbnailImageView;
}];
}
return cell;
}