SDK 版本 | 修订日期 | 修订说明 |
---|---|---|
0.1.0 | 2024.07.11 | 单选图片 & 单选视频 |
满足项目单选视频图片的低要求,并规避一些系统 Api 问题,也可作为系统 Api 的基础使用 Demo
![]() |
---|
To run the example project, clone the repo, and run pod install
from the Example directory first.
@interface LSJViewController ()
@property (nonatomic, strong) LSJImagePickerHelper *imagePickerHelper;
@end
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.imagePickerHelper = [LSJImagePickerHelper new];
}
/// 图片选择
- (void)pickImage{
__weak typeof(self)weakSelf = self;
[self.imagePickerHelper pickImageFromViewController:self completion:^(UIImage *image) {
__strong typeof(self)strongSelf = weakSelf;
if (strongSelf) {
self.resultLabel.text = [NSString stringWithFormat:@"图片:%@",image];
}
}];
}
/// 视频选择
- (void)pickVideo{
__weak typeof(self)weakSelf = self;
[self.imagePickerHelper pickVideoFromViewController:self completion:^(NSURL *url) {
__strong typeof(self)strongSelf = weakSelf;
if (strongSelf) {
self.resultLabel.text = [NSString stringWithFormat:@"视频:%@",url];
}
}];
}
iOS 11 +
lsj-ImagePickerHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'lsj-ImagePickerHelper'
lsj-ImagePickerHelper is available under the MIT license. See the LICENSE file for more info.
-
相册 Api 虽然没有说明什么时候要放弃这个 API ,但是苹果推荐了一个新的 API
PHPicker
(支持多选)。Will be removed in a future release, use PHPicker.
typedef NS_ENUM(NSInteger, UIImagePickerControllerSourceType) { UIImagePickerControllerSourceTypePhotoLibrary API_DEPRECATED("Will be removed in a future release, use PHPicker.", ios(2, API_TO_BE_DEPRECATED), visionos(1.0, API_TO_BE_DEPRECATED)), UIImagePickerControllerSourceTypeCamera API_UNAVAILABLE(visionos), UIImagePickerControllerSourceTypeSavedPhotosAlbum API_DEPRECATED("Will be removed in a future release, use PHPicker.", ios(2, API_TO_BE_DEPRECATED), visionos(1.0, API_TO_BE_DEPRECATED)), } API_UNAVAILABLE(tvos);
视频选择时不配置这个,系统默认会进行重新编码,存在片段丢失视频的选择视频重新编码后,无法获取到 url,导致视频选择失败,案例Demo:连接
self.imagePickerController.videoExportPreset = AVAssetExportPresetPassthrough;