How to upload an image from Parse to UIImageView (iOS)

I could ask for something very simple, but I will not be able to find a textbook or an example that would help me.

I learned how to extract string data from Parse, and now I'm trying to get the image, thinking it will be easier .. but I can not understand.

I am trying to upload 1 image (which I will change every day) to UIImageViewby extracting the image from my data browser on Parse.com.

Did anyone help?

Here is what I did:

- (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 point UIImageViewto download this information.

Thanks in advance!

+4
source share
4 answers

UIImageView . URL-, . SDWebImages

 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]]];

url , PFFile NSData UIImage

+8

, , ... PFFile....

PFFile *eventImage = [[loadimagesarray objectAtIndex:indexPath.row] objectForKey:@"ProfileImageFile"]; //ProfileImageFile is the name of key you stored the image file

if(eventImage != NULL)
{

    [eventImage getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {

        UIImage *thumbnailImage = [UIImage imageWithData:imageData];
        UIImageView *thumbnailImageView = [[UIImageView alloc] initWithImage:thumbnailImage];

        cell.yourimageview.image = thumbnailImageView.image;

    }];

}

, loadimagesarray, .

- (void)retrieveDetails
{
    PFQuery *query = [PFQuery queryWithClassName:@"outfitDay"];
    __block int totalNumberOfEntries = 0;
    [query orderByDescending:@"createdAt"];
    [query countObjectsInBackgroundWithBlock:^(int number1, NSError *error) {
        if (!error) {
            // The count request succeeded. Log the count

            totalNumberOfEntries = number1;

            if (totalNumberOfEntries > [loadimagesarray count])
            {
                NSLog(@"Retrieving data");
                //query.skip=[NSNumber numberWithInt:2300];
                [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
                    if (!error) {
                        // The find succeeded.
                        NSLog(@"Successfully retrieved %d chats.", objects.count);
                        int j=[loadimagesarray count];
                        if([objects count]>j)
                        {
                            [loadimagesarray addObjectsFromArray:objects];

                        }
                    }
                    else
                    {
                        // Log details of the failure
                        NSLog(@"Error: %@ %@", error, [error userInfo]);
                    }
                }];
            }

        } else
        {
            // The request failed, we'll keep the chatData count?
            number1 = [loadimagesarray count];
        }
    }];

}

, .

+5

PFImageView. PFFile Parse PFImageView ( -, ):

PFImageView *profileImageView;

// User thumbnail
PFFile *imageFile = [self.author objectForKey:FIELDNAME_PROFILE_PROFILEPICTUREFILE];
if (imageFile) {
    profileImageView.file = imageFile;
    [profileImageView loadInBackground];
} else {
    profileImageView.image = [UIImage imageNamed:@"AvatarPlaceholder.png"];
}

, , , ...

+1

Source: https://habr.com/ru/post/1527433/


All Articles