如何在屏幕截图中创建UI?

时间:2015-06-17 08:37:26

标签: iphone image photo imessage

我正在处理 iPhone 应用程序。我可以选择相册中的现有照片。应该有一个选项可以快速访问某些图像,就像在 iMessage 中一样。请查看随附的屏幕截图以获取更多信息。

有什么想法吗?

enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了问题的解决方案:

首先,我使用以下code从相册中读取最多20张图片。然后我将所有图像添加到UIScrollView。最后一个是More。如果用户点击它,它将显示iPhone默认"UIImagePickerController"以选择其他图像。

如果有人找到了更好的解决方案,请发布。

代码

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) {
}];