Taking Pictures and Movies
在我們的code和system兩者相互作用中,使用image picker拍攝照片和電影時(shí),主要有3個(gè)部分。
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一個(gè)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調(diào)用delegate object methods,code處理界面交互的結(jié)果
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:
-
實(shí)例化(instantiate)
- UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
-
配置(configure)
sourceType
mediaType
allowsEditing
delegate
-
彈出(present)
- full-screen present
-
處理代理方法(conform delegate method)
dismissModalViewControllerAnimated:
imagePickerController:didFinishPickingMediaWithInfo: