CSFileBrowser 0.1.2

CSFileBrowser 0.1.2

Mayur Amipara 维护。



  • 作者
  • Mayur Amipara

CSFileBrowser

Version License Platform

这是一个 iOS 库,可以显示带有页面数的图像、PDF、音频、视频。用户可以滚动浏览本地和远程的图像、PDF、音频、视频。

  • 图像缩放
  • 播放视频和音频
  • 自动生成视频缩略图
  • 处理和缓存网页中的照片
  • 处理和缓存网页中的视频缩略图
图像 视频
sample sample
PDF 音频
sample sample

需求

iOS 10.0+ | Xcode 9.0+ | Swift 4.2+

安装

CSFileBrowser 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'CSFileBrowser'
use_frameworks!

用法

以下代码示例展示如何实现,或查看示例项目。

    var attachments = ["https://www.gstatic.com/webp/gallery/1.jpg",
                      "https://www.gstatic.com/webp/gallery/2.jpg",
                      "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
                      "https://www.gstatic.com/webp/gallery/4.jpg",
                      "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3",
                      "http://www.pdf995.com/samples/pdf.pdf",
                      "https://www.gstatic.com/webp/gallery/5.jpg",
                      "http://techslides.com/demos/sample-videos/small.mp4",
                      "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-5.mp3",
                      "https://easychair.org/publications/easychair.docx",
                      "http://www.africau.edu/images/default/sample.pdf"]

如果附件来自文档目录

    
    if let documentsPathURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
    
        for document in listFilesFromDocumentsFolder() ?? []{
            attachments.append(documentsPathURL.appendingPathComponent("/\(document)").path)
        }
    }
    
    ##Get Docuement Directory Attachment
    func listFilesFromDocumentsFolder() -> [String]? {
    
        let fileMngr = FileManager.default;
    
        // Full path to documents directory
        let docs = fileMngr.urls(for: .documentDirectory, in: .userDomainMask)[0].path
    
        // List all contents of directory and return as [String] OR nil if failed
        return try? fileMngr.contentsOfDirectory(atPath:docs)
    }
    CSFileBrowser.openAttachmentSlider(navigation: self.navigationController!, attachment: attachments)

作者

Mayur Amipara

许可

CSFileBrowser遵循MIT许可证。更多信息请参阅LICENSE文件。