FlaneurImagePicker 0.7.1

FlaneurImagePicker 0.7.1

测试测试过
语言语言 SwiftSwift
许可证 MIT
发布最新发布2018年3月
SPM支持 SPM

Mickaël Floc'hlay 维护。



 
依赖项
IGListKit~> 3.0
ActionKit~> 2.1
Kingfisher~> 4.0
 

  • Flâneur

FlaneurImagePicker logo

CI Status Version License Platform Downloads

FlaneurImagePicker 是一个高度可定制的 iOS 图片选择器,允许用户从不同的来源(例如设备图库、设备相机、Instagram...)选择图片,如用于 Flâneur iOS 应用

特性

  • 支持多种图像来源
  • 可以轻松添加新图像来源
  • 按来源授权工作流程
  • 可定制的 UI 和行为

示例

要运行示例项目,克隆仓库,并首先从 Example 目录运行 pod install

要求

  • iOS 9
  • Swift 4

安装

FlaneurImagePicker 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中

pod "FlaneurImagePicker"

发布

要发布此pod版本,请参阅 Cocoapods 中的这些说明

入门

要启动 Flaneur Image Picker

#import FlaneurImagePicker

let imagePicker = FlaneurImagePickerController(userInfo: nil,
                                               sourcesDelegate: [],
                                               selectedImages: [])
imagePicker.delegate = self
self.present(imagePicker, animated: true, completion: nil)

查看提供的示例,以获取 FlaneurImagePickerControllerDelegate 协议的默认实现。

属性列表键

根据您打算集成的图像来源,您需要将不同来源的值添加到您的应用 .plist 文件中

<key>NSCameraUsageDescription</key>
<string>This application needs to access your camera</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>This application needs to access your photo library</string>

<key>InstagramClientID</key>
<string>YOUR_INSTAGRAM_CLIENT_ID</string>

<key>InstagramRedirectURI</key>
<string>YOUR_INSTAGRAM_REDIRECT_URI</string>

配置

要配置选择器,您可以使用选择器的 config 对象

// Changes the cancel button's title
imagePicker.config.cancelButtonTitle = "Cancel"

// Changes the done button's color
imagePicker.config.doneButtonColor = .brown

// Changes the order of the sections
 imagePicker.config.sectionsOrderArray = [.imageSources, .pickerView, .selectedImages]

// Changes the title for the one or more imageSources
imagePicker.config.titleForImageSource = [.instagram: "Insta."]

// Changes height for one or more sections
imagePicker.config.heightForSection = [.selectedImages: Int(UIScreen.main.bounds.height / CGFloat(3)), .imageSources: 50]

// You can find all the possible configurations in the documentation
// as well as an example in the Example directory of the repo
...

Instagram 支持

要配置 Instagram,请访问 Instagram 开发者网站

  • 创建一个账户
  • 转到 "管理客户端" 选项卡
  • 注册新的客户端
  • 填写信息
  • 返回到 "管理客户端" 选项卡
  • 点击 "管理" 按钮
  • 转到 "安全" 选项卡
  • 取消选中 "禁用隐式 OAuth"
  • 输入有效的重定向 URI(您选择的重定向 URI 并不重要,只要它是 https 地址即可,例如,您可以使用 https://google.com
  • 在您的 .plist 文件中复制重定向URI(如说明 这里 所述)
  • 按照说明 这里 在您的 .plist 文件中复制 ClientID

当您创建账户时,您处于沙盒模式,这意味着您只能请求用户最近20个媒体。

!!! 请记住,媒体指的是照片和视频,所以如果您在选择器中只看到10张照片,这意味着您只有10张照片,或者您最近的其他媒体是视频 !!!

要在沙盒模式下测试选择器,您需要将用户添加为沙盒用户,操作如下:

  • 转到“沙盒”选项卡
  • 输入用户名
  • 用户需要前往 Instagram开发者网站
  • 创建开发者账户
  • 前往沙盒邀请
  • 并接受邀请
  • 然后,只有这样他才能使用选择器

如果要从沙盒模式退出,您需要将应用提交给Instagram,请参阅文档以进行操作:Instagram开发者网站

文档

您可以在仓库的 docs 文件夹中找到文档。文档的 master 版本也在线可用 这里

作者

FlaneurApp, [email protected]

鸣谢

照片由Joanna Kosinska提供

许可

FlaneurImagePicker遵循MIT许可。有关更多信息,请参阅LICENSE文件。