2015-06-18 99 views
0

我在iOS应用程序中遇到了Parse的PFImageView问题。PFImageView不能在屏幕上显示

我有一个UITableView类的MainProfileTableViewCell的自定义UITableViewCell。这个UITableViewCell有一个名为profilePicture的UIImageView属性。基本上我想要做的是使用Parse的PFImageView,让它下载当前用户的个人资料图片,然后让UITableViewCell的profilePicture成为PFImageView(我正在使用故事板)。

问题是,当我运行应用程序并转到UITableView时,所有这一切都发生了,在配置文件图片应该是没有的地方。任何帮助?

(顺便说一句,这UITableView中只有一个单元格,现在,这是自定义的UITableViewCell。)

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

    MainProfileTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mainProfile" forIndexPath:indexPath]; 

    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

    PFImageView *profileImage = [[PFImageView alloc] init]; 
    profileImage.image = [UIImage imageNamed:@"Lincoln"]; 
    profileImage.file = currentUser[@"profilePicture"]; 
    [profileImage loadInBackground]; 

    cell.profilePicture = profileImage; 
    cell.profilePicture.layer.cornerRadius = cell.imageView.frame.size.width/2; 
    cell.profilePicture.clipsToBounds = YES; 

    [self.view addSubview:cell.profilePicture]; 

    return cell; 
} 

其他有用的信息: 的UIImageView的profileImage连接到的UIImageView在故事板。

回答

0

我解决它:调用loadInBackground方法之前添加

 profileImage.frame = cell.profilePicture.frame; 

+0

新问题是,尽管如此,图像不是圆形和圆形的:cell.profilePicture.layer.cornerRadius = cell.imageView.frame.size.width/2; cell.profilePicture.clipsToBounds = YES; – AlexC