试图从解析类设置UIImage

时间:2015-04-14 01:13:50

标签: ios objective-c parse-platform uiimage

我的parse.com应用程序上有一个名为“images”的类,这个类有一个名为“imageFile”的列,其中包含.png图像,我想知道的是我如何将parseImage设置为拍摄的图像从解析。这是我到目前为止所做的。

PFQuery *query = [PFQuery queryWithClassName:@"images"];

[query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {

    NSLog(@"Retrieved data");

    if (!error) {
        PFFile *file = [object objectForKey:@"imageFile"];

        [file getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
            if (!error) {
                parseImage = [UIImage imageWithData:data];
                // image can now be set on a UIImageView
            }
        }];
        //parseImage.file = file;

        //[imageHolder loadInBackground];
    }
}];

1 个答案:

答案 0 :(得分:0)

parseImage.file = file;
[parseImage loadInBackground];

PFImageView异步加载。使用它而不是手动检索文件。