所以,我正在尝试将我的数据库中存在的图像加载到PFImageView
MyAccount.h
@property (weak, nonatomic) IBOutlet PFImageView *profilePic;
MyAccount.m
-(void)viewDidLoad
{
[super viewDidLoad];
PFUser *cUser = [PFUser currentUser];
// Get the user's profile pic
if(cUser[PF_USER_PIC]) {
NSLog(@"cUser[PF_USER_PIC] exists, description: %@",
[cUser[PF_USER_PIC] description]);
self.profilePic.file = cUser[PF_USER_PIC];
[self.profilePic loadInBackground:
^(UIImage *image, NSError *error) {
if (!error)
NSLog(@"profilePic loadInBackground completed");
else {
NSLog(@"profilePic loadInBackground failed with error: %@", error);
}
}];
}
}
但不幸的是,这从未成功
2014-09-04 17:53:03.668 Rally[10281:60b]
cUser[PF_USER_PIC] exists, description: <PFFile: 0x17b070e80>
2014-09-04 17:53:03.972 Rally[10281:2ca3f]
profilePic loadInBackground failed with error:
Error Domain=Parse Code=150 "The operation couldn’t be completed. (Parse error 150.)"
我似乎无法通过谷歌搜索找到解决方案(结果不多)。任何人都可以了解可能在这里发生的事情吗?
请注意,我可以让saveInBackground
充满魅力。这只是我正在努力的入境方向!
编辑:更多信息
我尝试过使用UIImageView而不是PFImageView,而是将其链接起来。这是代码:
PFFile *imageData = (PFFile *)cUser[PF_USER_PIC];
[imageData getDataInBackgroundWithBlock:
^(NSData *data, NSError *error) {
if (error) {
NSLog(@"getDataInBackground error: %@", [error localizedDescription]);
}
else {
NSLog(@"getDataInBackground SUCCESS");
self.profilePic.image = [UIImage imageWithData:data];
}
}];
这似乎运作良好:
2014-09-09 12:30:31.822 Rally[2266:60b]
cUser[PF_USER_PIC] exists, description: <PFFile: 0xaaa2080>
2014-09-09 12:30:31.835 Rally[2266:60b]
getDataInBackground SUCCESS
然而,仍然没有图像出现!
最后但并非最不重要的是,如果我将[UIImage imageWithData:data]
替换为[UIImage imageNamed:@"some_local_image"]
,则效果非常好。所以UIImageView
肯定会被连接起来。