iOS-TZImagePickerController使用,调用相册,实现多选图片

安装pod

在Podfile文件中新增

复制代码
  pod 'TZImagePickerController'

添加好之后 pod install安装

TZImagePickerController使用

引入头文件

复制代码
#import <TZImagePickerController/TZImagePickerController.h>

@interface HandleMsgPictureView () <UINavigationControllerDelegate, UIImagePickerControllerDelegate, TZImagePickerControllerDelegate>


@end

唤起相册

复制代码
- (void)pushTZImagePickerController {
    //能选择的最大图片数
    NSInteger maxCount = 4 - self.photos.count;
    TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:maxCount columnNumber:4 delegate:self pushPhotoPickerVc:YES];
    imagePickerVc.isSelectOriginalPhoto = NO;
    [imagePickerVc setUiImagePickerControllerSettingBlock:^(UIImagePickerController *imagePickerController) {
        imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
    }];
    // 修改 字体颜色为黑色
    [imagePickerVc.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
    imagePickerVc.navigationBar.barTintColor = kWhiteColor;
    imagePickerVc.barItemTextColor = kBlackColor;
    imagePickerVc.allowPickingVideo = NO;
    imagePickerVc.allowPickingImage = YES;
    imagePickerVc.allowPickingOriginalPhoto = NO;
    imagePickerVc.allowPickingGif = NO;
    imagePickerVc.allowPickingMultipleVideo = NO;// 是否可以多选视频
    // 设置是否显示图片序号
    imagePickerVc.showSelectedIndex = YES;
    //  照片排列按修改时间升序
    imagePickerVc.sortAscendingByModificationDate = YES;
    imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
    if (@available(iOS 13.0, *)) {
        imagePickerVc.statusBarStyle = UIStatusBarStyleDarkContent;
    } else {
        imagePickerVc.statusBarStyle = UIStatusBarStyleDefault;
    }
    WeakSelf
    // 你可以通过block或者代理,来得到用户选择的照片.
    [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        //自定义的数据处理
        [weakSelf.photos addObjectsFromArray:photos];
        [self loadData];
    }];
   
    [self.currentViewController presentViewController:imagePickerVc animated:YES completion:nil];
}

/// 用户点击了取消
- (void)tz_imagePickerControllerDidCancel:(TZImagePickerController *)picker {
     NSLog(@"cancel");
}
相关推荐
xiaobai17830 分钟前
测试工程师入门AI技术 - 前序:跨越焦虑,从优势出发开启学习之旅
人工智能·学习
北岛寒沫41 分钟前
北京大学国家发展研究院 经济学原理课程笔记(第二十一课 金融学基础)
经验分享·笔记·学习
扑火的小飞蛾1 小时前
网络安全小白学习路线图 (基于提供文档库)
学习·安全·web安全
优雅的潮叭1 小时前
c++ 学习笔记之 malloc
c++·笔记·学习
薛不痒2 小时前
深度学习之优化模型(数据预处理,数据增强,调整学习率)
深度学习·学习
昵称已被吞噬~‘(*@﹏@*)’~3 小时前
【RL+空战】学习记录03:基于JSBSim构造简易空空导弹模型,并结合python接口调用测试
开发语言·人工智能·python·学习·深度强化学习·jsbsim·空战
我想我不够好。3 小时前
学到的知识点 1.8
学习
旖旎夜光4 小时前
Linux(9)
linux·学习
浩瀚地学5 小时前
【Java】常用API(二)
java·开发语言·经验分享·笔记·学习
chao_6666665 小时前
解决 PowerShell 中文乱码问题
网络·学习·powershell