UIImagePickerController(一)

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

  1. code初始化和present一个UIImagePickerController

You instantiate and modally present a camera interface—an instance of the UIImagePickerController class.

  1. 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

  1. 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:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容