2015-06-18 94 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