Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从多个PFUser对象检索PFFiles错误_Ios_Objective C_Uitableview_Parse Platform - Fatal编程技术网

Ios 从多个PFUser对象检索PFFiles错误

Ios 从多个PFUser对象检索PFFiles错误,ios,objective-c,uitableview,parse-platform,Ios,Objective C,Uitableview,Parse Platform,我有一个名为allMyContacts的数组,它存储PFUser对象(当前用户的朋友)。每个用户都有一个配置文件映像,我想在UITableViewCell中靠近他们的用户名设置它 我可以显示它们的名称,但当我尝试将图像加载到PFImageView中时出错。错误为:”-[UIImageView设置文件:]:无法识别的选择器发送到实例0x17EBEA0' 我认为错误在这一行:PFFile*file=[user objectForKey:@“imageFile”],但不知道是什么。每个用户在image

我有一个名为
allMyContacts
的数组,它存储
PFUser
对象(当前用户的朋友)。每个用户都有一个配置文件映像,我想在UITableViewCell中靠近他们的用户名设置它

我可以显示它们的名称,但当我尝试将图像加载到
PFImageView
中时出错。错误为:
”-[UIImageView设置文件:]:无法识别的选择器发送到实例0x17EBEA0'

我认为错误在这一行:
PFFile*file=[user objectForKey:@“imageFile”],但不知道是什么。每个用户在
imageFile
列下都有一个现有的配置文件图像,因此它不能为零。我怀疑表视图也是一个原因,因为我在不同的视图中使用了几乎相同的代码,在不同的视图中,我设置了概要文件图像,它可以工作

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

    FriendsCell *cell = [self.tableViewTwo dequeueReusableCellWithIdentifier:@"friendsDevCell"];

    if (self.allMyContact == nil) {
        return cell;
    }
    else {
        PFUser *user = [self.allMyContact objectAtIndex:indexPath.row];

            PFFile *file = [user objectForKey:@"imageFile"];

            cell.profilkepView.file = file;

            [cell.profilkepView loadInBackground];

        cell.mySimpleContactUsernameLabel.text = user.username;

        return cell;

            }


  }

除非您在profilIView中有一个自定义文件参数,否则我不相信您可以直接调用cell.profilkepView.file。您可能想尝试以下方法:


cell.profilkepView.image=[UIImage ImageName:file]

我查看了解析文档,我认为您需要自己加载URL。这是我的第二次尝试:

PFFile *file = [user objectForKey:@"imageFile"];
NSURL *imageURL = [[NSURL alloc] initWithString:file.url];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
cell.profilkepView.image = [UIImage imageWithData:imageData];

它不起作用。我需要使用.file,因为我使用的是PFImageView。我敢肯定,它在没有表视图的其他地方运行良好。