Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load an image from Parse into a UIImageView (iOS)

I might be asking something really easy, but I can't manage to find a tutorial or example that would help me.

I have learned how to retrieve string data from Parse and now I am trying to retrieve an image thinking it would be easier.. but I can't figure it out.

I am trying to load 1 image (that I'll be changing every day) in the UIImageView, retrieving the image from my data browser in Parse.com.

Could somebody help please?

Here is what I've done:

- (void)viewDidLoad {
    [super viewDidLoad];

    [self performSelector:@selector(retrieveFromParse)];
}

- (void) retrieveFromParse {

    PFQuery *retrieveImage = [PFQuery queryWithClassName:@"outfitDay"];
    [retrieveImage findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            loadimageArray = [[NSArray alloc] initWithArray:objects];
        }
    }];         
}

I am missing the part where you indicate the UIImageView to load that information.

Thanks in advance!!

like image 898
adriennemhenry Avatar asked Dec 07 '22 03:12

adriennemhenry


1 Answers

You can set image in UIImageView with the help of this code.If you want to set image in imageview from with the help of url you can try this code.For this you have to download SDWebImages library

 PFObject *objFollow1 = ["your array of PFObject" objectAtIndex:your index];
 PFFile *image = [objFollow1 objectForKey:@"your key"];
 NSLog(@"%@",teaserImage.url);
 [your imageview setImageWithURL:[NSURL URLWithString:[teaserImage url]]];

And if you don't want to download image form url then you have to convert this PFFile in to NSData and then convert in to UIImage

like image 122
Vishal Jani Avatar answered Dec 25 '22 23:12

Vishal Jani