swift - PresentViewController如何显示 View ?

标签 swift uiimagepickercontroller

我很好奇presentViewController 对第一个参数imagePickerController 的作用。鉴于我分配 imagePickerController 属性的方式,presentViewController 会使用所有这些信息来显示 View 吗?

@IBAction func imageFromPhotoLibrary(sender: UITapGestureRecognizer) {
    // Hide the keyboard.
    myTextField.resignFirstResponder()

    // UIImagePickerController is a view controller that lets a user pick media from their photo library.
    let imagePickerController = UIImagePickerController()

    // Only allow photos to be picked, not taken.
    imagePickerController.sourceType = .PhotoLibrary

    // Make sure ViewController is notified when the user picks an image.
    imagePickerController.delegate = self

    presentViewController(imagePickerController, animated: true, completion: nil)
}

最佳答案

presentViewController 不会使用任何选项。您传入的 imagePickerController 将使用这些选项。

由于 Apple API 设计得非常好,presentViewController 只做一件事 (SRP),并且完全按照它所说的去做...向您呈现 View Controller 通过它。

imagePickerController 负责控制图像选择器的 View

关于swift - PresentViewController如何显示 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36679508/

相关文章:

ios - UIImagePickerController:如何允许编辑但隐藏裁剪选项

swift - 使用 Swift 2.2 的 Cordova 应用程序

swift - 在 Vapor 中的哪里创建自己的文件?

iphone - 拍摄图像并在 UIImagePickerController 中点击 'USE' 后随机出现黑屏

iphone - UIImagePickerController subview 未调用委托(delegate)。用作 modalViewController

iPhone 如何显示我的文档目录中的照片?

ios - Swift - 从另一个类访问 mapView 时遇到问题

swift - 更改 XLFORM 行的值

swift - 尝试发送数据以查看时出现映射问题

iphone - 在iPhone中不使用AVCaptureSession调用UIImagePickerControl的方法