Uitableview 从解析类获取图像

Uitableview 从解析类获取图像,uitableview,parse-platform,fetch,Uitableview,Parse Platform,Fetch,新手,伙计们。我已经设法从Parse类到table视图获取了文本。在同一个类中,我有另一个列,其中我放置了相关的图像文件,但不知何故,我无法获取图像文件。如果你能帮我解决这个问题,我会很高兴的。解析类名是News,我想得到的列是imageFile。这是我的密码 .h文件 #import <UIKit/UIKit.h> #import <Parse/Parse.h> #import "TableCell.h" @interface ViewController : UIV

新手,伙计们。我已经设法从Parse类到table视图获取了文本。在同一个类中,我有另一个列,其中我放置了相关的图像文件,但不知何故,我无法获取图像文件。如果你能帮我解决这个问题,我会很高兴的。解析类名是News,我想得到的列是imageFile。这是我的密码

.h文件

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "TableCell.h"

@interface ViewController : UIViewController <UITableViewDelegate> {

NSArray *events;
}
@property (weak, nonatomic) IBOutlet UITableView *newsTable;

@end
我的手机

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface TableCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;


@end

这将获取关联的文件并将其放入cell.imageView中,该文件是PFImageView(UIImageView的解析版本):

刚过

PFObject *tempObject = [events objectAtIndex:indexPath.row];
cell.TitleLabel.text = [tempObject objectForKey:@"Event"];
写在下面几行

PFFile *imageFile = [tempObject objectForKey:@"image"];
PFImageView *imageView = [[PFImageView alloc] init];
imageView.file = imageFile;
[imageView loadInBackground:^(UIImage *img,NSError *error){

    if(!error)
    {
        UIImageView *yourImageView = [[UIImageView alloc] init];
        yourImageView.image = imageView.image;
        /*OR*/
        cell.imageView.image = imageView.image;
    }
}];

这可能会让您继续。

谢谢您的回答,但在我尝试了这一点之后,我得到了一个SIGABRT错误:Interface Builder文件中的未知类PFImageView。编写该代码时是否找到PFImageView?它是解析API的一部分。你真的是指界面生成器文件吗?代码是否接受PFImageView*imageView=[[PFImageView alloc]init]?代码查找PFImageView。看起来API工作正常。但是是的,界面生成器找不到它。我在walle84的链接中看到其他人也有同样的问题。我在链接中找不到任何问题。。。?您得到的错误是什么?我遇到了与本文讨论的相同的错误,但现在我设法使其正常工作。再次感谢您的支持。嗨,这可能会帮助您。还有什么请告诉我!谢谢你的信息。但是我不明白如何在我的代码中实现它;cell.TitleLabel.text=[tempObject objectForKey:@“事件”]写在下面的行中<代码>PFFile*imageFile=[tempObject objectForKey:@“image”];PFImageView*imageView=[[PFImageView alloc]init];imageView.file=imageFile;[图像视图加载背景]非常感谢您的回答walle84。这对我有用。
 PFObject *tempObject = [events objectAtIndex:indexPath.row];
 cell.TitleLabel.text = [tempObject objectForKey:@"Event"];   

 PFFile *imageFile = [tempObject objectForKey:@"imageFile"];
 if (imageFile) {
     cell.imageView.file = imageFile;
     [cell.imageView loadInBackground];
 } else {
     cell.imageView.image = [UIImage imageNamed:@"AvatarPlaceholder.png"];
 }
PFObject *tempObject = [events objectAtIndex:indexPath.row];
cell.TitleLabel.text = [tempObject objectForKey:@"Event"];
PFFile *imageFile = [tempObject objectForKey:@"image"];
PFImageView *imageView = [[PFImageView alloc] init];
imageView.file = imageFile;
[imageView loadInBackground:^(UIImage *img,NSError *error){

    if(!error)
    {
        UIImageView *yourImageView = [[UIImageView alloc] init];
        yourImageView.image = imageView.image;
        /*OR*/
        cell.imageView.image = imageView.image;
    }
}];