【发布时间】:2015-02-14 01:39:59
【问题描述】:
Parse.com 刚刚更新了他们的 SDK 以支持本地存储。但是在安装新的 SDK 之后,PFFile 出现了一些问题。同样的方法我用了很长时间了,但现在我使用的是新的 SDK,我无法让它工作。
这是我的代码:
.h 文件
@property (strong, nonatomic) IBOutlet PFFile *iconPhoto;
.m 文件
cell.iconPhoto.image = [UIImage imageNamed:@"placeholder.png"]; // placeholder image
cell.iconPhoto.file = (PFFile *)object[@"icon"]; // remote image
[cell.iconPhoto loadInBackground:^(UIImage *image, NSError *error) {
cell.iconPhoto.image = image;
cell.userInteractionEnabled = YES;
}];
当我运行时,我得到these errors (link)
其他人有同样的问题吗?
更新:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
});
static NSString *CellIdentifier = @"Cell";
MainTVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
PFObject *object = [self.currentCategories objectAtIndex:indexPath.row];
cell.mainLabel.text = object[@"name"];
cell.userInteractionEnabled = YES;
if (![object[@"icon"] isEqual:[NSNull null]]) {
cell.image = [UIImage imageNamed:@"loading.png"]; // placeholder image
cell.iconPhoto = (PFFile *)object[@"icon"]; // remote image
[cell.iconPhoto getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (!error && imageData) {
cell.image = [UIImage imageWithData:imageData];
cell.userInteractionEnabled = YES;
}
}];
}
return cell;
}
【问题讨论】:
-
哦,你刚刚换了屏幕截图……而且屏幕截图中的代码和这里的代码不一样……
-
您正在结合两个不同的概念...如果您使用的是 PFImageView,则无需使用
getDataInBackground。 -
您刚刚删除了您的评论... PFImageView 是哪个?
-
@LyndseyScott 抱歉,我把截图弄混了。我现在已经修好了。
-
PFImageView 是什么?
标签: ios objective-c parse-platform pffile