#import "ViewController.h"
#import <CTAssetsPickerController.h>
@interface ViewController () <CTAssetsPickerControllerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// label.text = NSLocalizedStringFromTable(@"Name", @"Test", nil);
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){
dispatch_async(dispatch_get_main_queue(), ^{
CTAssetsPickerController *picker = [[CTAssetsPickerController alloc] init];
picker.delegate = self;
picker.assetCollectionSubtypes =
@[@(PHAssetCollectionSubtypeSmartAlbumUserLibrary),
@(PHAssetCollectionSubtypeAlbumRegular)];
[self presentViewController:picker animated:YES completion:nil];
});
}];
}
#pragma mark - <CTAssetsPickerControllerDelegate>
- (void)assetsPickerController:(CTAssetsPickerController *)picker didFinishPickingAssets:(NSArray *)assets
{
// 關(guān)閉圖片選擇界面
[picker dismissViewControllerAnimated:YES completion:nil];
// 取出所有選擇的圖片
PHImageRequestOptions *requestOptions = [[PHImageRequestOptions alloc] init];
requestOptions.resizeMode = PHImageRequestOptionsResizeModeExact;
requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
PHImageManager *manager = [PHImageManager defaultManager];
NSInteger index = 0;
for (PHAsset *asset in assets) {
[manager requestImageForAsset:asset
targetSize:CGSizeMake(100, 100)
contentMode:PHImageContentModeAspectFill
options:requestOptions
resultHandler:^(UIImage *image, NSDictionary *info){
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = image;
imageView.frame = CGRectMake(110 * (index % 3), 110 * (index / 3), 100, 100);
[self.view addSubview:imageView];
}];
index++;
}
}
@end
photo
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- [作者前言] 偉大的法國雕塑藝術(shù)家羅丹曾經(jīng)說過:“美是到處都有的。對于我們的眼睛,不是缺少美,而是缺少發(fā)現(xiàn)。” ...
- 不知不覺畢業(yè)已經(jīng)幾個月了,已經(jīng)從一個學(xué)生成為一名職場人士。在16年6月份的時候,揣著新買的相機,拍了不少校園里各個...
- ios8 以及之后使用了photo framework這個新的框架,也就是,如果我們在xcode8 上進(jìn)行使用的時...
- 我之前也回答過這樣一個問題,說當(dāng)身體出現(xiàn)什么信號就不能在飲酒了,很多人回答說當(dāng)酒量突然增加或下降,消化不良脾胃不好...