Giter Club home page Giter Club logo

lgphotobrowser's Introduction

LGPhotoBrowser Travis License MIT 

前言

  • 此框架经过实际项目锤炼,使用过程中改善了众多bug,在稳定性、流畅性以及内存消耗方面做了大量优化。但难免还有缺陷,希望同仁们在使用过程中发现并指正,并提issue!

  • 注意:如果照相机不需要连拍功能,建议采用系统相机,经测试,自定义相机的体验和内存消耗均劣于系统相机。

  • 相册优化方法:iOS中自定义相册功能性能优化

  • 如果对您有帮助,记得star,动力源自鼓励

简介

  • 此框架包含三个模块:图片浏览器,相册选择器,自定义照相机(支持单拍、连拍);

  • 界面仿照微信的样式;

  • 加载本地照片速度快;

  • 图片浏览器采用后台预加载手段,完全消除大图浏览的卡顿现象;

  • 具备相册已选组别记忆功能;

  • 支持夜间模式;

1.图片浏览器

CXLSlideList Screenshot

2.相册选择器

CXLSlideList Screenshot CXLSlideList Screenshot

3.自定义相机

CXLSlideList Screenshot CXLSlideList Screenshot CXLSlideList Screenshot

添加到工程

第一步:拷贝Class文件文件夹和Images文件夹到工程.

第二步:'#import "LGPhoto.h"'

备注:

  • 自定义相册通常会根据需求做调整,所以不支持cocoaPods

  • 用到的第三方:

    图片下载 等待框
    SDWebImage DACircularProgressView

    如果你的项目中已经存在这两个框架,请手动删除Third文件夹中对应的框架。

初始化

初始化相册选择器,里面包括大图浏览

/**
 *  初始化相册选择器
 */
- (void)presentPhotoPickerViewControllerWithStyle:(LGShowImageType)style {
    LGPhotoPickerViewController *pickerVc = [[LGPhotoPickerViewController alloc] initWithShowType:style];
    pickerVc.status = PickerViewShowStatusCameraRoll;
    pickerVc.maxCount = 9;   // 最多能选9张图片
    pickerVc.delegate = self;
    self.showType = style;
    [pickerVc showPickerVc:self];
}

如果单独使用图片浏览器,也很简单:初始化+实现数据源方法

/**
 *  初始化图片浏览器
 */
- (void)pushPhotoBroswerWithStyle:(LGShowImageType)style{
    LGPhotoPickerBrowserViewController *BroswerVC = [[LGPhotoPickerBrowserViewController alloc] init];
    BroswerVC.delegate = self;
    BroswerVC.dataSource = self;
    BroswerVC.showType = style;
    self.showType = style;
    [self presentViewController:BroswerVC animated:YES completion:nil];
}
#pragma mark - LGPhotoPickerBrowserViewControllerDataSource

- (NSInteger)photoBrowser:(LGPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{if (self.showType == LGShowImageTypeImageBroswer) {
        return self.LGPhotoPickerBrowserPhotoArray.count;
    } else if (self.showType == LGShowImageTypeImageURL) {
        return self.LGPhotoPickerBrowserURLArray.count;
    } else {
        NSLog(@"非法数据源");
        return 0;
    }
}
//在这里,需要把图片包装成LGPhotoPickerBrowserPhoto对象,然后return即可。
- (id<LGPhotoPickerBrowserPhoto>)photoBrowser:(LGPhotoPickerBrowserViewController *)pickerBrowser photoAtIndexPath:(NSIndexPath *)indexPath{
    if (self.showType == LGShowImageTypeImageBroswer) {
        return [self.LGPhotoPickerBrowserPhotoArray objectAtIndex:indexPath.item];
    } else if (self.showType == LGShowImageTypeImageURL) {
        return [self.LGPhotoPickerBrowserURLArray objectAtIndex:indexPath.item];
    } else {
        NSLog(@"非法数据源");
        return nil;
    }
}

详见ViewController.m,注释很清楚

环境支持

iOS7及更高

LICENSE

LGPhotoBrowser is released under the MIT license. See LICENSE for details.

lgphotobrowser's People

Contributors

bryant1410 avatar gang544043963 avatar liujinlongxa avatar youngwifemoliy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lgphotobrowser's Issues

ZLCameraViewController的- (UIImage *)cutImage:(UIImage *)srcImg方法内存泄漏

此处创建 CGImageRef subImageRef 的没有释放 请在末尾加上CGImageRelease(subImageRef);
//裁剪image

  • (UIImage *)cutImage:(UIImage *)srcImg {
    //注意:这个rect是指横屏时的rect,即屏幕对着自己,home建在右边
    CGRect rect = CGRectMake((srcImg.size.height / CGRectGetHeight(self.view.frame)) * 70, 0, srcImg.size.width * 1.33, srcImg.size.width);
    CGImageRef subImageRef = CGImageCreateWithImageInRect(srcImg.CGImage, rect);
    CGFloat subWidth = CGImageGetWidth(subImageRef);
    CGFloat subHeight = CGImageGetHeight(subImageRef);
    CGRect smallBounds = CGRectMake(0, 0, subWidth, subHeight);
    //旋转后,画出来
    CGAffineTransform transform = CGAffineTransformIdentity;
    transform = CGAffineTransformTranslate(transform, 0, subWidth);
    transform = CGAffineTransformRotate(transform, -M_PI_2);
    CGContextRef ctx = CGBitmapContextCreate(NULL, subHeight, subWidth,
    CGImageGetBitsPerComponent(subImageRef), 0,
    CGImageGetColorSpace(subImageRef),
    CGImageGetBitmapInfo(subImageRef));
    CGContextConcatCTM(ctx, transform);
    CGContextDrawImage(ctx, smallBounds, subImageRef);
    CGImageRef cgimg = CGBitmapContextCreateImage(ctx);
    UIImage *img = [UIImage imageWithCGImage:cgimg];

    CGImageRelease(subImageRef);
    CGContextRelease(ctx);
    CGImageRelease(cgimg);
    return img;
    }

拖到IOS11 里工程报错了

being linked (8.0)
Undefined symbols for architecture x86_64:
"OBJC_CLASS$_LGPhotoPickerViewController", referenced from:
objc-class-ref in NewCaledarController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

原图只是看大小,没有实际功能

图片多选,返回的LGPhotoAssets中并没有提示这个图选择原图还是直接选择,原图只是查看大小,对之后代码控制没有什么帮助,希望选择原图的功能能够给出一个标识,代表这个图片用户是否选择的是原图。谢谢

navigationBar设置为不隐藏,页面下沉

我想保留navigationBar,但是不隐藏navigationBar的话,页面会整体下沉。要怎么设置才不会下沉呢?navigationBar.translucent = NO;navigationBar不透明。

搜索相册的显示


出现了这样一个问题.同事的手机里面有N多"金沙赌场"等等这种垃圾的信息,邀请.
项目在搜索相册的时候会搜到很多相片数为0的相册,其实显示这些相片数为0的相册是无意义的.
所以在LGPhotoPickerDatas第64行中加上

            if (pickerGroup.assetsCount > 0)
            {
                [groups addObject:pickerGroup];
            }

应该会好一些

内存使用率很高

博主,如果手机相册中照片很多的情况下载选择照片选择器在点击大图浏览情况下。不断的滑动切换相片很快内存会增上去从而导致奔溃闪退

滴滴滴,在不在

if(self.callback){
self.callback(self.images);
AFLog(@"%@",self.images);
}
这个返回的数据是(
"<ZLCamera: 0x1c0431800>",
"<ZLCamera: 0x1c042c320>",
"<ZLCamera: 0x1c4420ba0>"
)
麻烦问下,这个self.images 怎么转成图片啊,这个数据不是图片,也不是nsdata,怎么转成图片

CocoaPods失败

通过CocoaPods进行安装,出现以下错误:
warning: Could not find remote branch 1.1.0 to clone.
fatal: Remote branch 1.1.0 not found in upstream origin

但是使用pod search 'LGPhotoBrowser'却能查询到结果,而且版本号也是对的,不知道别人有没有遇到这样的问题。

分类命名问题

同时引用masonry和LG,会导致冲突,原因就是使用的分类属性命名冲突的,建议使用lg_xx。比如lg_width

选够 9 张后退出再进入

选够 9 张后,退出页面,再次进入,取消选择一张图片,在选择,会报已经选择 9 张,实际上只有 8 张,应该在删除后,重算一下 maxCount

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.