您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页swift <Photos.framework >

swift <Photos.framework >

来源:二三娱乐

iOS8.0 swift <Photos.framework >


先上个效果图吧!
效果图

\

整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、点击关注哦!

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务