【问题标题】:PFImageView issue: Can't display images from Parse in table view cellsPFImageView 问题:无法在表格视图单元格中显示来自 Parse 的图像
【发布时间】:2014-05-31 12:27:07
【问题描述】:

我正在尝试在UITableViewCell 中显示带有PFImageView 的图像。在另一个视图控制器中,我成功地完成了它(没有 tableview)。如果self.senderId 不是零,我会查询图像并将其加载到单元格中,但SUCCESS 日志不会出现在控制台中,因此我可能错过了查询中的某些内容(在我的其他视图我在块内使用 [self.profilePic loadInBackground]。(但是应用程序正在运行并且我没有收到任何错误,只是图像视图中没有出现任何内容。)如果有人可以帮助我,我会很高兴解决这个问题,因为我不知道我的实现有什么问题。

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (self.senderId == nil) {
        NSLog(@"No updates.");
    }
    else {
        PFQuery *queryImage = [PFQuery queryWithClassName:@"UserPicture"];
        [queryImage whereKey:@"user" equalTo:self.senderId];
        [queryImage orderByDescending:@"createdAt"];
        [queryImage getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
            if (error) {
                NSLog(@"ERROR.");
            } else {
                PFFile *file = [object objectForKey:@"imageFile"];
                self.senderPicture = file;

                NSLog(@"SUCCESS");
            }
        }];
    }

    [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(reloadTable) userInfo:nil repeats:YES];

    [self setupUIForInput];

}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


    OutputTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellThree"];

    cell.textOutput.text = self.senderId;

    if (self.senderId == nil) {
        NSLog(@"No updates.");
    }
    else {
    cell.self.profilePic.file = self.senderPicture;
    [cell.self.profilePic loadInBackground];

    }
        return cell;
}

-(void)reloadTable{
    [tableViewThree reloadData];
}

我也试过这个:

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (self.senderId == nil) {
        NSLog(@"No updates.");
    }
    else {
        PFQuery *queryImage = [PFQuery queryWithClassName:@"UserPicture"];
        [queryImage whereKey:@"user" equalTo:self.senderId];
        [queryImage orderByDescending:@"createdAt"];
        [queryImage getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
            if (error) {
                NSLog(@"ERROR.");
            } else {
                self.file = [object objectForKey:@"imageFile"];


                NSLog(@"SUCCESS");
            }
        }];
    }

    [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(reloadTable) userInfo:nil repeats:YES];

    [self setupUIForInput];

}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


    OutputTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellThree"];

    cell.textOutput.text = self.senderId;

    if (self.senderId == nil) {
        NSLog(@"No updates");
    }
    else {
    cell.self.profilePic.file = self.file;
    [cell.self.profilePic loadInBackground];

    }
        return cell;
}

【问题讨论】:

    标签: ios objective-c uitableview parse-platform


    【解决方案1】:

    问题解决了。

    问题是我为 self.senderId [queryImage whereKey:@"user" equalTo:self.senderId]; 使用了 NSString 而不是 PFUser 对象 [queryImage whereKey:@"user" equalTo:currentuser];

    【讨论】:

      猜你喜欢
      • 2014-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 1970-01-01
      • 2014-11-23
      相关资源
      最近更新 更多