我很好奇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/