Latest 0.0.2
Homepage https://github.com/WillieWu/HBPhotoBrowser
License MIT
Platforms ios 8.0, requires ARC
Frameworks Photos
Authors

iOS8.0 swift


先上个效果图吧!

效果图

整Demo个写下来,没花多少时间。主要也就是拿swift练手。

这个里面最主要的就是优化内存消耗问题了,一直控制在15M以内!

使用iphone5(9.2)也就是在展示所有小图片的时候,滚动灰常流畅。甚至比系统相册滚动的时候流畅。本人亲测哈。。


工程目录文件

目录

1.导入所需文件

导入<Photos.framework >HBPhotoBrowser-Main

2.使用

实例化HBPhotoBrowser

    //实例化,设置代理<HBBaseViewControllerDelegate>
    let rootVc = HBPhotoBrowser(delegate: self)
    //最大可选择数量(默认最大可选9张)
    rootVc.maxPhotos = 3

    let navBrowser = HBNavgationBrowser(rootViewController: rootVc)

    self.presentViewController(navBrowser, animated: true, completion: nil)

HBBaseViewControllerDelegate方法

@objc protocol HBBaseViewControllerDelegate: NSObjectProtocol {

/**
 选取的所有图片

 - parameter baseVc: baseVc
 - parameter photos: [photo]
 */
optional func baseViewController(baseVc: HBBaseViewController, didPickPhotos photos: [photo])
/**
 取消,返回到根视图

 - parameter baseVc: baseVc
 */
optional func baseViewcontroller(didCancle baseVc: HBBaseViewController)
/**
 选取图片到达上限

 - parameter baseVc: baseVc
 */
optional func baseViewController(baseVc: HBBaseViewController, didMaxCount maxCount: Int)

}

实现HBBaseViewControllerDelegate方法


    extension ViewController: HBBaseViewControllerDelegate {

    func baseViewcontroller(didCancle baseVc: HBBaseViewController) {
        print("取消 - 我要回老家了")
        baseVc.dismissViewControllerAnimated(true, completion: nil)

    }

    func baseViewController(baseVc: HBBaseViewController, didPickPhotos photos: [photo]) {
        print("一共选取" + String(photos.count) + "张图片")
        baseVc.dismissViewControllerAnimated(true, completion: nil)

    }

    func baseViewController(baseVc: HBBaseViewController, didMaxCount maxCount: Int) {

        let errorMessage = "小兄弟,最多选择" + String(maxCount) + "张"

        let alter = UIAlertView(title: nil, message: errorMessage, delegate: nil, cancelButtonTitle: "确定")
        alter.show()

     }
 }

关于<Photos.framework >更多的介绍

点击这里

如果这个文章帮到了你,一定给我Star、点击关注哦!

项目地址 欢迎围观

Latest podspec

{
    "name": "HBPhotoBrowser",
    "version": "0.0.2",
    "summary": "IOS photo album selection framework",
    "description": "u8fd9u662fu4e00u4e2au5728iOSu4e0au9762u7b80u5355u7684u9009u62e9u89c6u9891u548cu7167u7247u7684u5e93uff0cu4f7fu7528u65b9u4fbfu7684u72e0u54dfuff01u4e48u4e48u54d2~",
    "homepage": "https://github.com/WillieWu/HBPhotoBrowser",
    "license": "MIT",
    "authors": {
        "hongbin.wu": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "swift_version": "3.2",
    "source": {
        "git": "https://github.com/WillieWu/HBPhotoBrowser.git",
        "tag": "0.0.2"
    },
    "source_files": "HBPhotoBrowser/HBPhotoBrowser-Main/*.swift",
    "resource_bundles": {
        "HBPhotoBrowser": [
            "HBPhotoBrowser/HBPhotoBrowser-Main/Assets/*"
        ]
    },
    "frameworks": "Photos",
    "requires_arc": true
}

Pin It on Pinterest

Share This