我很好奇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)
}
答案 0 :(得分:0)
presentViewController
不会使用任何选项。您传入的imagePickerController
将使用这些选项。
由于Apple API设计得非常好,presentViewController
做了一件事(SRP),并完全按照它的说法做了...... 提供了传递它的视图控制器。
imagePickerController
负责控制图像选择器的视图。