Giter Site home page Giter Site 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

gang544043963 avatar youngwifemoliy avatar bryant1410 avatar liujinlongxa avatar

Watchers

James Cloos avatar Joker avatar

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.