测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布最新发布 | 2015年7月 |
由Uzysjung macAir维护。
替代 UIImagePickerController ,您可以拍照并且选择多张照片和视频
UzysAssetsPickerController 的功能:
pod 'UzysAssetsPickerController'
添加到您的 Podfile。#import "UzysAssetsPickerController.h"
如果您想自定义 UzysAssetsPickerController 的外观,您可以初始化 UzysAppearanceConfig 实例,并配置其属性,然后在初始化 UzysAssetsPickerController 之前调用
+ (void)setUpAppearanceConfig:(UzysAppearanceConfig *)config
的 UzysAssetsPickerController
示例代码如下
UzysAppearanceConfig *appearanceConfig = [[UzysAppearanceConfig alloc] init];
appearanceConfig.finishSelectionButtonColor = [UIColor blueColor];
appearanceConfig.assetsGroupSelectedImageName = @"checker";
[UzysAssetsPickerController setUpAppearanceConfig:appearanceConfig];
有关更多可配置的属性,请参阅 UzysAppearanceConfig.h
UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
picker.delegate = self;
picker.maximumNumberOfSelectionMedia = 2;
[self presentViewController:picker animated:YES completion:^{
}];
- (void)uzysAssetsPickerController:(UzysAssetsPickerController *)picker didFinishPickingAssets:(NSArray *)assets
{
__weak typeof(self) weakSelf = self;
if([[assets[0] valueForProperty:@"ALAssetPropertyType"] isEqualToString:@"ALAssetTypePhoto"]) //Photo
{
[assets enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
ALAsset *representation = obj;
UIImage *img = [UIImage imageWithCGImage:representation.defaultRepresentation.fullResolutionImage
scale:representation.defaultRepresentation.scale
orientation:(UIImageOrientation)representation.defaultRepresentation.orientation];
weakSelf.imageView.image = img;
*stop = YES;
}];
}
else //Video
{
ALAsset *alAsset = assets[0];
UIImage *img = [UIImage imageWithCGImage:alAsset.defaultRepresentation.fullResolutionImage
scale:alAsset.defaultRepresentation.scale
orientation:(UIImageOrientation)alAsset.defaultRepresentation.orientation];
weakSelf.imageView.image = img;
ALAssetRepresentation *representation = alAsset.defaultRepresentation;
NSURL *movieURL = representation.url;
NSURL *uploadURL = [NSURL fileURLWithPath:[[NSTemporaryDirectory() stringByAppendingPathComponent:@"test"] stringByAppendingString:@".mp4"]];
AVAsset *asset = [AVURLAsset URLAssetWithURL:movieURL options:nil];
AVAssetExportSession *session =
[AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
session.outputFileType = AVFileTypeQuickTimeMovie;
session.outputURL = uploadURL;
[session exportAsynchronouslyWithCompletionHandler:^{
if (session.status == AVAssetExportSessionStatusCompleted)
{
NSLog(@"output Video URL %@",uploadURL);
}
}];
}
}
UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
picker.delegate = self;
picker.maximumNumberOfSelectionVideo = 0;
picker.maximumNumberOfSelectionPhoto = 3;
UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
picker.delegate = self;
picker.maximumNumberOfSelectionVideo = 3;
picker.maximumNumberOfSelectionPhoto = 0;
UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
picker.delegate = self;
picker.maximumNumberOfSelectionVideo = 4;
picker.maximumNumberOfSelectionPhoto = 3;
UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
picker.delegate = self;
picker.maximumNumberOfSelectionMedia = 5;