Code Monkey home page Code Monkey logo

silencelove / hxphotopicker Goto Github PK

View Code? Open in Web Editor NEW
3.0K 54.0 643.0 57.91 MB

图片/视频选择器 - 支持LivePhoto、GIF图片选择、3DTouch预览、在线下载iCloud上的资源、编辑图片/视频、浏览网络图片 功能 Imitation wx photo/image picker - support for LivePhoto, GIF image selection, 3DTouch preview, Download the resources on iCloud online, browse the web image function

Home Page: https://github.com/SilenceLove/HXPhotoPicker

License: MIT License

Objective-C 0.64% Ruby 0.28% Swift 99.04% Metal 0.04%
picker 3d-touch gif livephoto photokit uiimagepickercontroller icloud browser previewimage photopicker

hxphotopicker's Issues

HXPhotoSubViewCell问题

你的HXPhotoSubViewCell SDWebImage方法 [self.imageView sd_setImageWithURL:[NSURL URLWithString:self.model.networkPhotoUrl] placeholderImage:self.model.thumbPhoto options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) 爆红

模糊

真机相册胶卷选择图片的界面照片太模糊了

直接使用HXPhotoViewController选择图片后在代理方法里面布局,图片顺序不正确

  • (HXPhotoManager *)manager
    {
    if (!_manager) {
    _manager = [[HXPhotoManager alloc] initWithType:HXPhotoManagerSelectedTypePhotoAndVideo];
    _manager.openCamera = YES;
    _manager.cacheAlbum = YES;
    _manager.lookLivePhoto = YES;
    _manager.open3DTouchPreview = YES;
    _manager.cameraType = HXPhotoManagerCameraTypeSystem;
    _manager.photoMaxNum = 6;
    _manager.maxNum = 6;
    _manager.saveSystemAblum = NO;
    }
    return _manager;
    }

  • (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    {
    HXPhotoViewController *vc = [[HXPhotoViewController alloc] init];
    vc.delegate = self;
    vc.manager = self.manager;
    [self presentViewController:[[UINavigationController alloc] initWithRootViewController:vc] animated:YES completion:nil];
    }

  • (void)photoViewControllerDidNext:(NSArray<HXPhotoModel *> *)allList Photos:(NSArray<HXPhotoModel *> *)photos Videos:(NSArray<HXPhotoModel *> *)videos Original:(BOOL)original
    {
    [HXPhotoTools getImageForSelectedPhoto:photos type:HXPhotoToolsFetchHDImageType completion:^(NSArray<UIImage *> *images) {
    //这里的images数组顺序不是我之前选择的,多张选择才会出现这个问题,一张一张选择是不会出现问题,用UIImageView显示出来的结果,已经变顺序了。
    }];
    }

代理方法里面拿到的images数组,里面的顺序不是我自己之前选择的顺序,求解决,很无语,不知道怎么解决。

发现一个崩溃bug

当我我设置只是选择照片时,设置最大选择9张,当选择9之后,照片后面的选择按钮消失,点击最后一张图删除崩溃,崩溃位置HXPhotoTools.m

+ (void)getSelectedListResultModel:(NSArray<HXPhotoModel *> *)selectedList complete:(void (^)(NSArray<HXPhotoResultModel *> *, NSArray<HXPhotoResultModel *> *, NSArray<HXPhotoResultModel *> *))complete {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSMutableArray *models = [NSMutableArray array];
        NSMutableArray *photos = [NSMutableArray array];
        NSMutableArray *videos = [NSMutableArray array];
        
        for (HXPhotoModel *photoModel in selectedList) {
            HXPhotoResultModel *resultModel = [[HXPhotoResultModel alloc] init];
            resultModel.index = photoModel.endCollectionIndex; // 定位的崩溃位置在这里
            if (photoModel.asset) {
                if (photoModel.subType == HXPhotoModelMediaSubTypeVideo) {
                    if ([photoModel.avAsset isKindOfClass:[AVURLAsset class]]) {
                        AVURLAsset *urlAsset = (AVURLAsset *)photoModel.avAsset;
                        resultModel.videoURL = urlAsset.URL;
                    }
                    resultModel.type = HXPhotoResultModelMediaTypeVideo;
                    resultModel.videoIndex = photoModel.videoIndex;
                }else {
                    resultModel.photoIndex = photoModel.endIndex;
                    resultModel.type = HXPhotoResultModelMediaTypePhoto;
                }
                resultModel.avAsset = photoModel.avAsset;
                PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init];
                options.networkAccessAllowed = NO;
                __weak typeof(self) weakSelf = self;
                [photoModel.asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput * _Nullable contentEditingInput, NSDictionary * _Nonnull info) {
                    BOOL error = [info objectForKey:PHContentEditingInputErrorKey];
                    //            BOOL cloud = [[info objectForKey:PHContentEditingInputResultIsInCloudKey] boolValue];
                    BOOL cancel = [[info objectForKey:PHContentEditingInputCancelledKey] boolValue];
                    
                    if (!error && !cancel && contentEditingInput) {
                        resultModel.fullSizeImageURL = contentEditingInput.fullSizeImageURL;
                        if (resultModel.type == HXPhotoResultModelMediaTypePhoto) {
                            resultModel.displaySizeImage = contentEditingInput.displaySizeImage;
                        }else {
                            resultModel.displaySizeImage = photoModel.thumbPhoto;
                        }
                        resultModel.fullSizeImageOrientation = contentEditingInput.fullSizeImageOrientation;
                        resultModel.creationDate = contentEditingInput.creationDate;
                        resultModel.location = contentEditingInput.location;
                        if ([contentEditingInput.avAsset isKindOfClass:[AVURLAsset class]]) {
                            AVURLAsset *urlAsset = (AVURLAsset *)contentEditingInput.avAsset;
                            resultModel.videoURL = urlAsset.URL;
                            resultModel.avAsset = contentEditingInput.avAsset;
                        }
                        [weakSelf sortResultModel:resultModel total:selectedList.count models:models photos:photos videos:videos completion:^(NSArray *all, NSArray *photos, NSArray *videos) {
                            dispatch_async(dispatch_get_main_queue(), ^{
                                if (complete) {
                                    complete(all,photos,videos);
                                }
                            });
                        }];
                    }
                }];
            }else {
                resultModel.creationDate = [NSDate date];
                resultModel.displaySizeImage = photoModel.previewPhoto;
                if (photoModel.subType == HXPhotoModelMediaSubTypePhoto) {
                    resultModel.photoIndex = photoModel.endIndex;
                    resultModel.type = HXPhotoResultModelMediaTypePhoto;
                    resultModel.fullSizeImageOrientation = photoModel.previewPhoto.imageOrientation;
                    NSData *imageData;
                    NSString *suffix;
                    if (UIImagePNGRepresentation(photoModel.previewPhoto)) {
                        //返回为png图像。
                        imageData = UIImagePNGRepresentation(photoModel.previewPhoto);
                        suffix = @"png";
                    }else {
                        //返回为JPEG图像。
                        imageData = UIImageJPEGRepresentation(photoModel.previewPhoto, 1.0);
                        suffix = @"jpeg";
                    }
                    NSString *fileName = [[self uploadFileName] stringByAppendingString:[NSString stringWithFormat:@".%@",suffix]];
                    NSString *fullPathToFile = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
                    [imageData writeToFile:fullPathToFile atomically:YES];
                    resultModel.fullSizeImageURL = [NSURL fileURLWithPath:fullPathToFile];
                }else {
                    resultModel.videoIndex = photoModel.videoIndex;
                    resultModel.type = HXPhotoResultModelMediaTypeVideo;
                    resultModel.videoURL = photoModel.videoURL;
                }
                [self sortResultModel:resultModel total:selectedList.count models:models photos:photos videos:videos completion:^(NSArray *all, NSArray *photos, NSArray *videos) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        if (complete) {
                            complete(all,photos,videos);
                        }
                    });
                }];
            }
            
        }
    });
}

HXPhotoView嵌套在子view中添加图片问题

HXPhotoView直接添加在controller中
设置frame
photoView.frame = CGRectMake(12, 100, width - 24, 0);
是可以点击添加
但是
如果把HXPhotoView嵌套在子view中
photoView.frame = CGRectMake(12, 100, width - 24, 0);
这样设置点击加号添加图片,走不到cell点击的这个方法
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

如果把HXPhotoView嵌套在子view中photoView.frame这样设置
photoView.frame = CGRectMake(12, 100, width - 24, 84);
就可以走到点击cell的方法来

如果把HXPhotoView添加在在controller的ChildViewController的view中 无论如何怎么设置frame都走不到cell点击方法了

但是都可以正常的显示出来

我的项目是一个多层级嵌套界面,不管怎么添加都点击不了

iPad上HXPhotoView不能选择

建议将HXPhotoView中的- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex换成- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

demo2的图片回显是怎么做的呢?

demo2 的图片回显 很清晰
但是 我是 如何获取 图片这种清洗图片呢

我原本 获取 model.thumbPhoto 但是图片很模糊

后来这样写

  • (void)photoViewControllerDidNext:(NSArray *)allList Photos:(NSArray *)photos Videos:(NSArray *)videos Original:(BOOL)original
    {

//
// dispatch_sync(dispatch_get_main_queue(), ^{
[HXPhotoTools fetchOriginalForSelectedPhoto:photos completion:^(NSArray<UIImage *> *images) {

        for(int i = 0; i < images.count; i++) {

          // start 图片 压缩 放入 沙盒
            NSString *imgPath = [self saveImage: images[i] name:[NSString stringWithFormat:@"%@%lu",[self getTime:nil] ,(unsigned long)_imgArr.count]];
            [_imgArr addObject: imgPath];
          // end  图片 压缩 放入 沙盒


        }
        _manager = nil;
    }];

// });

}

但这是个 异步 的 有时候 回显的图片还没处理好 回显就是失败了 如果加同步锁 很消耗时间

有啥 好的方法么

权限问题

关闭了照相机、相册的权限,可以跳转权限未打开界面吗?

设置最大图片数的bug

5212a0eb6715dcd05d1849ee4fab1947

设置了最大图片数为4张的时候 demo2 的最后一个按钮没有隐藏
_manager.photoMaxNum = 4;

点击加号,可进入选择相册页面,点击照相机,就报照片数上限

CocoaPods集成问题

指定版本号后会报错,找不到
[!] Unable to find a specification for HXWeiboPhotoPicker~> 2.0.6
不指定版本号 显示安装的是1.2版
Installing HXWeiboPhotoPicker (1.2)
CocoaPods上的库该升级了额。

框架很赞!

跟环信冲突了...

环信用的SDWEBIMAGE只支持3.8...你的需要4.0.0...我只想说..环信那个坑逼..

选择图片的问题

进入大图,点击右上取消按钮取消当前选择图片,点下一步,返回主页面还是会有刚才的图片,没有取消掉。

不能编译,报错

clang: error: cannot specify -o when generating multiple output files

swift3.0混编环境下,无法编译......

iCloud上的视频无法下载到本地

选择视频的时候如果这个视频在iCloud上,没在本地保存,点击预览的时候封面图闪一下之后就一片空白了,不会自动下载播放。另外,查看的图片如果是在iCloud上保存,点击预览是可以自动下载到本地的。

iOS 8.0 iPhone 5C 内存不足崩溃

2017-09-11 14:25:54.783 微博照片选择[792:10708] Received memory warning.
2017-09-11 14:25:57.229 微博照片选择[792:10779] Connection to assetsd was interrupted or assetsd died
2017-09-11 14:25:58.259 微博照片选择[792:10708] Received memory warning.

选中livePhoto后程序崩溃

[两个demo中都有这种现象,就是当选择添加图片后并不点击下一步,而是继续滑动预览,在选择一张后再滑动预览程序就会崩溃;

错误日志:
微博照片选择[1995:713665] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHLivePhotoRequestOptions setVersion:]: unrecognized selector sent to instance 0x12c5e6a50'
*** First throw call stack:
(0x183285900 0x1828f3f80 0x18328c61c 0x1832895b8 0x18318d68c 0x1000d4e70 0x10009f040 0x1000f0f58 0x188132f78 0x188132a7c 0x1859cf814 0x1859cf6c8 0x1834fa1e8 0x1832271f8 0x18323d634 0x18323cd6c 0x18323aac4 0x183169680 0x184678088 0x187fe0d90 0x1000d110c 0x182d0a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

代理方法遍历数组,获取图片二进制,为空

Uploading A954244B-B7C9-4773-821D-9C20BA359045.png…

  • (void)photoViewChangeComplete:(NSArray *)allList Photos:(NSArray *)photos Videos:(NSArray *)videos Original:(BOOL)isOriginal
    {
    NSLog(@"%ld - %ld - %ld",allList.count,photos.count,videos.count);
    NSLog(@"%@",photos);
    [allList enumerateObjectsUsingBlock:^(HXPhotoModel *photo, NSUInteger idx, BOOL *stop) {
    NSLog(@"%@",photo.imageData);
    }];

}
此方法打印图片二进制位空

相册向下偏移64

有没有和我遇见一样的情况,demo2的选择相册,然后整个相册向下偏移了64.???????

iOS8适配问题

在iOS8系统下运行打开相册会在HXPhotoViewController.m中
self.isCapabilityAvailable = self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable;

这句代码会报错

因为
@property (nonatomic, readonly) UIForceTouchCapability forceTouchCapability NS_AVAILABLE_IOS(9_0); // unspecified: UIForceTouchCapabilityUnknown

判断一下版本,可以运行出来 会出什么问题吗
if (iOS9Later) { self.isCapabilityAvailable = self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable; }

崩溃

1.点击拍照按钮,进入拍照页面,点击右上角——摄像头反转按钮,直接崩溃

2.拍照时时正方形窗口,拍出来的照片确实长方形,并且两边收窄了,不知道是什么原因

3.建议:拍照按钮,也可以在外面以UIAlertSheet的方式显示拍照功能

图片大小计算问题

同样的图片,在demo里和微博同时选择相同几张图片,点击原图大小计算不一样

关于拍照之后显示的问题

点击拍照之后,随便拍一张照片,然后点击右方向图标,页面转场完成后,自动帮忙选择了一张照片,但是怕的照片不是这张,提个需求,连拍模式

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.