如何制作屏幕截图中的 UI?
How to make an UI as it is in the screenshot?
我正在开发 iPhone 应用程序。我可以选择 select 来自 相册 的现有照片。在 iMessage 中应该有一个快速访问某些图像的选项。请查看随附的屏幕截图以获取更多信息。
有什么想法吗?
我找到了我的问题的解决方案:
首先,我正在使用下面的 code
从相册中读取最多 20 张最近的图像。然后我将所有图像添加到 UIScrollView
。最后一个是More
。如果用户点击它,它将显示 iPhone 默认 "UIImagePickerController"
以选择其他图像。
如果有人找到更好的解决方案,请post。
代码
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) {
}];
我正在开发 iPhone 应用程序。我可以选择 select 来自 相册 的现有照片。在 iMessage 中应该有一个快速访问某些图像的选项。请查看随附的屏幕截图以获取更多信息。
有什么想法吗?
我找到了我的问题的解决方案:
首先,我正在使用下面的 code
从相册中读取最多 20 张最近的图像。然后我将所有图像添加到 UIScrollView
。最后一个是More
。如果用户点击它,它将显示 iPhone 默认 "UIImagePickerController"
以选择其他图像。
如果有人找到更好的解决方案,请post。
代码
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) {
}];