Taking Pictures and Movies
在我们的code和system两者相互作用中,使用image picker拍摄照片和电影时,主要有3个部分。
Taking a picture or movie with an image picker controller is a three part process that proceeds as an interplay between your code and the system
- code初始化和present一个UIImagePickerController
You instantiate and modally present a camera interface—an instance of the UIImagePickerController class.
- system管理camera interface,take picture or movie or cancel the operation
The system manages the camera interface and the user’s interaction with it. In typical use, the user either takes a picture or movie, or cancels the operation
- system调用delegate object methods,code处理界面交互的结果
The system invokes your image picker controller delegate object’s methods, which in turn handle the results of the user’s interaction—for example, by saving a new picture to the Camera Roll album. The delegate is also responsible for dismissing the camera interface.
Creating and Configuring a Camera Interface
-
条件测试(condition test)
UIRequiredDeviceCapabilities info.plist
isSourceTypeAvailable:
-
实例化(instantiate)
- UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
-
配置(configure)
sourceType
mediaType
allowsEditing
delegate
-
弹出(present)
- full-screen present
-
处理代理方法(conform delegate method)
dismissModalViewControllerAnimated:
imagePickerController:didFinishPickingMediaWithInfo: