基于 PickerController 功能模块封装相关 - iOS

 Now 第三方库 GitHub 地址飞机票: GitHub-JKImagePicker


首先包含所需的头文件,并添加代理.

Code 如下:

#pragma mark -更换头像相关

- (void)changeHeadImg {

alertConImg= [UIAlertController alertControllerWithTitle:nilmessage:nilpreferredStyle:UIAlertControllerStyleActionSheet];

[alertConImg addAction:[UIAlertAction actionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:^(UIAlertAction*_Nonnullaction) {

/**取消*/

}]];

[alertConImg addAction:[UIAlertAction actionWithTitle:@"拍照"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {

/**拍照*/

}]];

[alertConImg addAction:[UIAlertAction actionWithTitle:@"从手机相册选取"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {

/**从手机相册选取*/

JKImagePickerController*imgPickerCon = [[JKImagePickerController alloc] init];

imgPickerCon.delegate=self;

imgPickerCon.showsCancelButton=YES;//显示取消按钮

imgPickerCon.allowsMultipleSelection=YES;//允许多个选择

imgPickerCon.minimumNumberOfSelection= 1;//最小选择的数量

imgPickerCon.maximumNumberOfSelection= 9;//最大选择的数量

imgPickerCon.selectedAssetArray=self.arrSletedHeadImg;//装载选择的照片

YQBaseNavigationController*navCon = [[YQBaseNavigationController alloc] initWithRootViewController:imgPickerCon];

[self presentViewController:navCon animated:YES completion:^{

//

}];

}]];

[self presentViewController:alertConImg animated:YES completion:^{

/**调相机功能PickerCon*/

}];

}

#pragma mark -相机或相册获取图片回调相关代理方法

- (void)imagePickerController:(JKImagePickerController*)imagePicker didSelectAsset:(JKAssets*)asset isSource:(BOOL)source {

[imagePicker dismissViewControllerAnimated:YES completion:^{

//

}];

}

- (void)imagePickerController:(JKImagePickerController*)imagePicker didSelectAssets:(NSArray*)assets isSource:(BOOL)source {

self.arrSletedHeadImg= [NSMutableArray arrayWithArray:assets];

for(int i = 0; i

JKAssets*asset = [self.arrSletedHeadImg objectAtIndex:i];

ALAssetsLibrary*lib = [[ALAssetsLibrary alloc] init];

[lib assetForURL:asset.assetPropertyURLresultBlock:^(ALAsset*asset) {

//

}failureBlock:^(NSError*error) {

NSLog(@"YQMyInfoViewController.h --- imgPickerCon --- error --- %@", error);

}];

}

[imagePicker dismissViewControllerAnimated:YES completion:^{

/**点击完成回调*/

}];

}

- (void)imagePickerControllerDidCancel:(JKImagePickerController*)imagePicker {

[imagePicker dismissViewControllerAnimated:YES completion:^{

//

}];

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值