How to make an UI as it is in the screenshot?

79 views Asked by At

I am working on an iPhone application. I have an option to select existing photos from Album. There should be an option for quick access for some images as it is in iMessage. Please check the attached screenshot for more information.

Any idea ?

enter image description here

1

There are 1 answers

0
jfalexvijay On BEST ANSWER

I found the solution for my question:

First I am reading maximum 20 recent images from Photo Album using below code. Then I am adding all the images into UIScrollView. The last one is More. If user click on it, it will show iPhone default "UIImagePickerController" to choose other images.

If anybody found a better solution, please post it.

Code

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    [group setAssetsFilter:[ALAssetsFilter allPhotos]];
    [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *asset, NSUInteger index, BOOL *innerStop) {
        if (asset) {
            if ([self.stackForImages count] >= 20) {
                // Stop the enumerations
                *stop = YES;
                *innerStop = YES;
                [self initializeMedia];
            } else {
                ALAssetRepresentation *representation = [asset defaultRepresentation];
                NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
                [workingDictionary setObject:[asset valueForProperty:ALAssetPropertyType] forKey:UIImagePickerControllerMediaType];
                [workingDictionary setObject:[UIImage imageWithCGImage:[asset thumbnail]] forKey:UIImagePickerControllerEditedImage];
                [workingDictionary setObject:[UIImage imageWithCGImage:[representation fullScreenImage]] forKey:UIImagePickerControllerOriginalImage];
                [workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:UIImagePickerControllerReferenceURL];
                [self.stackForImages addObject:workingDictionary];
            }
        }
    }];
    if ([self.stackForImages count] > 0) {
        [self initializeMedia];
    }
} failureBlock: ^(NSError *error) {
}];