我对presentViewController对第一个参数imagePickerController所做的事情感到好奇。考虑到我分配imagePickerController属性的方式,presentViewController会使用所有这些信息来显示视图吗?
@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),并且完全按照它所说的去做...为您提供传递给它的视图控制器。imagePickerController
负责控制图像选择器的视图。