首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >PFQueryTableViewController不加载图像parse.com

PFQueryTableViewController不加载图像parse.com
EN

Stack Overflow用户
提问于 2014-02-21 21:09:31
回答 3查看 620关注 0票数 2

目前,我使用以下代码:

代码语言:javascript
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier     forIndexPath:indexPath];

if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}



PFFile *file = [object valueForKeyPath:@"exercicio.foto"];
[file getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
    cell.imageView.image = [[UIImage alloc] initWithData:data];
    [cell setNeedsLayout];
}];

return cell;
}

这是可行的,但图像加载时间太长,并且滚动时视觉效果不是很好。我试图使用PFTableViewCell,但当我试图从parse中获取PFFile时,我收到消息,无法识别的选择器被发送到cell.imageView.file行中的实例。现在,当我将storyboard中的类更改为PFTableViewCell时,应用程序不会崩溃,但也不会加载图像。

这是使我崩溃的代码,或者如果我将storyboard更改为PFTableViewCell,它不会显示图像。

代码语言:javascript
复制
- (PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {

static NSString *CellIdentifier = @"Cell";
PFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier    forIndexPath:indexPath];

if (!cell) {
    cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault     reuseIdentifier:CellIdentifier];
}
cell.imageView.file = [object valueForKeyPath:@"exercicio.foto"];

return cell;
}

我真的需要帮助,我已经尝试了很多方法,但似乎都不起作用。谢谢。

EN

回答 3

Stack Overflow用户

发布于 2014-07-31 10:27:21

这是可行的

代码语言:javascript
复制
PFFile *thumbnail = object[@"imageFile"];

    cell.imageView.image = [UIImage imageNamed:@"857-rocket.png"];
    cell.imageView.file = thumbnail;

    [cell.imageView loadInBackground];
票数 1
EN

Stack Overflow用户

发布于 2014-02-28 21:04:49

如果问题是您的图像加载时间太长,我建议您创建图像的缩略图版本,然后在表视图中使用这些图像。然后,如果您从表视图转到细节视图,则会加载完整大小的图像。

票数 0
EN

Stack Overflow用户

发布于 2014-02-28 23:38:39

在设置PFImageView的文件值之后,必须调用loadInBackground

代码语言:javascript
复制
- (void)loadInBackground

解析文件属性的文档描述确认:

解析器服务器上存储图像的远程文件。请注意,在调用loadInBackground:之前,下载不会开始。

还有一个带有完成块的方法:

代码语言:javascript
复制
- (void)loadInBackground:(void ( ^ ) ( UIImage *image , NSError *error ))completion
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21935386

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档