【问题标题】:iOS 10 - UIImagePickerController for both Photos and CameraiOS 10 - 照片和相机的 UIImagePickerController
【发布时间】:2017-04-15 01:45:12
【问题描述】:

当用户在 iOS 10 中打开他们的短信应用并点击相机图标时,会出现一个选择器视图,允许用户点击他们照片库中的照片或从同一视图中拍摄照片。 Swift 3 中是否有任何东西允许第三方应用程序使用这种类型的 ImagePickerController?到目前为止,我只知道允许应用程序将照片库或相机专门指定为源类型的方法。

【问题讨论】:

  • iOS SDK 不提供这样的控件。您必须自己编写或找到其他人编写的库来复制相同的功能。

标签: ios swift uiimagepickercontroller


【解决方案1】:

我认为 iMessage 的应用没有使用 UIImagePickerController 来实现你提到的那个功能。

使用 Photos.framework 和 AVFoundation.framework 可以创建你期望的 UIViewController。

UIImagePickerController 只是一个简单的高级控制器,缺乏功能,缺乏定制。很难用它做复杂的接口。

【讨论】:

    【解决方案2】:

    我之前在我的一个应用程序中使用过ALCameraViewController。它允许您拍照、裁剪,并且有一个按钮可以从库中选择图像。只需将 pod 添加到您的项目中即可。

    用法

    使用这个组件再简单不过了。添加导入 ALCameraViewController 到你的控制器文件的顶部。

    在视图控制器中

    let croppingEnabled = true
    let cameraViewController = CameraViewController(croppingEnabled: croppingEnabled) { [weak self] image, asset in
        // Do something with your image here.
        // If cropping is enabled this image will be the cropped version
    
        self?.dismiss(animated: true, completion: nil)
    }
    
    present(cameraViewController, animated: true, completion: nil)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 2014-09-20
      • 1970-01-01
      • 2012-12-18
      相关资源
      最近更新 更多