UIImagePickerController

//

//  UIImagePickerController.h

//  UIKit

//

//  Copyright (c) 2008-2015 Apple Inc. All rights reserved.

//

 

#import <Foundation/Foundation.h>

#import <UIKit/UINavigationController.h> //与导航有关联

#import <UIKit/UIKitDefines.h>

 

NS_ASSUME_NONNULL_BEGIN

 

@class UIImage; //告诉编译器要用到UIImage类

@protocol UIImagePickerControllerDelegate; //写UIImagePickerControllerDelegate的协议

 

 

#pragma mark======== 五个枚举 ====

 

//UIImagePickerControllerSourceType 图片获取的来源(途径)

 

typedef NS_ENUM(NSInteger, UIImagePickerControllerSourceType) {

    UIImagePickerControllerSourceTypePhotoLibrary, 图库

    UIImagePickerControllerSourceTypeCamera,  相机

    UIImagePickerControllerSourceTypeSavedPhotosAlbum 相册

} __TVOS_PROHIBITED; 

 

 

 // QualityType 像素的质量(大小)

typedef NS_ENUM(NSInteger, UIImagePickerControllerQualityType) {

    UIImagePickerControllerQualityTypeHigh = 0,       // highest quality

    UIImagePickerControllerQualityTypeMedium = 1,     // medium quality, suitable for transmission via Wi-Fi 

    UIImagePickerControllerQualityTypeLow = 2,         // lowest quality, suitable for tranmission via cellular network

    UIImagePickerControllerQualityType640x480 NS_ENUM_AVAILABLE_IOS(4_0) = 3,    // VGA quality

    UIImagePickerControllerQualityTypeIFrame1280x720 NS_ENUM_AVAILABLE_IOS(5_0) = 4,

    UIImagePickerControllerQualityTypeIFrame960x540 NS_ENUM_AVAILABLE_IOS(5_0) = 5,

} __TVOS_PROHIBITED;

 

 

//CameraCaptureMode 相机的捕捉模式

typedef NS_ENUM(NSInteger, UIImagePickerControllerCameraCaptureMode) {

    UIImagePickerControllerCameraCaptureModePhoto, 图片拍摄模式

    UIImagePickerControllerCameraCaptureModeVideo  录像模式

} __TVOS_PROHIBITED;

 

//CameraDevice 相机摄像头前置还是后置

typedef NS_ENUM(NSInteger, UIImagePickerControllerCameraDevice) {

    UIImagePickerControllerCameraDeviceRear, 后置 

    UIImagePickerControllerCameraDeviceFront 前置

} __TVOS_PROHIBITED;

 

//CameraFlashMode 📷闪光灯的模式

typedef NS_ENUM(NSInteger, UIImagePickerControllerCameraFlashMode) {

    UIImagePickerControllerCameraFlashModeOff  = -1, 关闭

    UIImagePickerControllerCameraFlashModeAuto = 0, 自动

    UIImagePickerControllerCameraFlashModeOn   = 1  打开

} __TVOS_PROHIBITED;

 

 

#pragma mark======== 通过以下的key值,可以获得对应的值 ====

// info dictionary keys 与协议里的字典info相对应

UIKIT_EXTERN NSString *const UIImagePickerControllerMediaType __TVOS_PROHIBITED;      // an NSString (UTI, i.e. kUTTypeImage)

UIKIT_EXTERN NSString *const UIImagePickerControllerOriginalImage __TVOS_PROHIBITED;  // a UIImage -OriginalImage- 

UIKIT_EXTERN NSString *const UIImagePickerControllerEditedImage __TVOS_PROHIBITED;    // a UIImage -EditedImage- 

UIKIT_EXTERN NSString *const UIImagePickerControllerCropRect __TVOS_PROHIBITED;       // an NSValue (CGRect) -CropRect-

UIKIT_EXTERN NSString *const UIImagePickerControllerMediaURL __TVOS_PROHIBITED;       // an NSURL  -MediaURL-

UIKIT_EXTERN NSString *const UIImagePickerControllerReferenceURL        NS_AVAILABLE_IOS(4_1) __TVOS_PROHIBITED;  // an NSURL that references an asset in the AssetsLibrary framework

UIKIT_EXTERN NSString *const UIImagePickerControllerMediaMetadata       NS_AVAILABLE_IOS(4_1) __TVOS_PROHIBITED;  // an NSDictionary containing metadata from a captured photo

UIKIT_EXTERN NSString *const UIImagePickerControllerLivePhoto NS_AVAILABLE_IOS(9_1) __TVOS_PROHIBITED;  // a PHLivePhoto

 

 

 

#pragma mark======== UIImagePickerController ====

 

//继承自UINavigationController的UIImagePickerController类

 

NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UIImagePickerController : UINavigationController <NSCoding>

 

//判断 获取途径是否可用

+ (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType;                 // returns YES if source is available (i.e. camera present)

+ (nullable NSArray<NSString *> *)availableMediaTypesForSourceType:(UIImagePickerControllerSourceType)sourceType; // returns array of available media types (i.e. kUTTypeImage)

 

 

//CameraDevice 相机摄像头前置还是后置

+ (BOOL)isCameraDeviceAvailable:(UIImagePickerControllerCameraDevice)cameraDevice                   NS_AVAILABLE_IOS(4_0); // returns YES if camera device is available 

 

//CameraFlashMode 📷闪光灯的模式

+ (BOOL)isFlashAvailableForCameraDevice:(UIImagePickerControllerCameraDevice)cameraDevice           NS_AVAILABLE_IOS(4_0); // returns YES if camera device supports flash and torch.

//CameraCaptureMode 相机的捕捉模式

+ (nullable NSArray<NSNumber *> *)availableCaptureModesForCameraDevice:(UIImagePickerControllerCameraDevice)cameraDevice NS_AVAILABLE_IOS(4_0); // returns array of NSNumbers (UIImagePickerControllerCameraCaptureMode)

 

 

 

// 遵循的协议方法

@property(nullable,nonatomic,weak)      id <UINavigationControllerDelegate, UIImagePickerControllerDelegate> delegate;

 

@property(nonatomic)           UIImagePickerControllerSourceType     sourceType;                                                        // default value is(默认值是) UIImagePickerControllerSourceTypePhotoLibrary(图库).

 

@property(nonatomic,copy)      NSArray<NSString *>                   *mediaTypes;

    // default value is an array containing kUTTypeImage.

 

@property(nonatomic)           BOOL                                  allowsEditing NS_AVAILABLE_IOS(3_1);     // replacement for -allowsImageEditing; default value is NO.(是否允许编辑,默认值是NO)

 

@property(nonatomic)           BOOL                                  allowsImageEditing NS_DEPRECATED_IOS(2_0, 3_1);  //DEPRECATED 不推荐使用了

 

#pragma mark======== 关于相机的一些属性 ====

// video properties apply only if mediaTypes includes kUTTypeMovie

@property(nonatomic)           NSTimeInterval                        videoMaximumDuration NS_AVAILABLE_IOS(3_1); // default value is 10 minutes. 摄像的最大持续时间

 

@property(nonatomic)           UIImagePickerControllerQualityType    videoQuality NS_AVAILABLE_IOS(3_1);         // default value is UIImagePickerControllerQualityTypeMedium. If the cameraDevice does not support the videoQuality, it will use the default value. 默认值是UIImagePickerControllerQualityTypeMedium(中等像素).

 

 

 

// camera additions available only if sourceType is UIImagePickerControllerSourceTypeCamera.

@property(nonatomic)           BOOL                                  showsCameraControls NS_AVAILABLE_IOS(3_1);   // set to NO to hide all standard camera UI. default is YES

@property(nullable, nonatomic,strong) __kindof UIView                *cameraOverlayView  NS_AVAILABLE_IOS(3_1);   // set a view to overlay the preview view.

@property(nonatomic)           CGAffineTransform                     cameraViewTransform NS_AVAILABLE_IOS(3_1);   // set the transform of the preview view.

 

- (void)takePicture NS_AVAILABLE_IOS(3_1);                                                   

// programatically initiates still image capture. ignored if image capture is in-flight.

// clients can initiate additional captures after receiving -imagePickerController:didFinishPickingMediaWithInfo: delegate callback

 

- (BOOL)startVideoCapture NS_AVAILABLE_IOS(4_0);

- (void)stopVideoCapture  NS_AVAILABLE_IOS(4_0);

 

@property(nonatomic) UIImagePickerControllerCameraCaptureMode cameraCaptureMode NS_AVAILABLE_IOS(4_0); // default is(默认是拍摄图片模式) UIImagePickerControllerCameraCaptureModePhoto

@property(nonatomic) UIImagePickerControllerCameraDevice      cameraDevice      NS_AVAILABLE_IOS(4_0); // default is(默认是调用后置摄像) UIImagePickerControllerCameraDeviceRear

@property(nonatomic) UIImagePickerControllerCameraFlashMode   cameraFlashMode   NS_AVAILABLE_IOS(4_0); // default is UIImagePickerControllerCameraFlashModeAuto.(默认是自动闪光灯) 

 

// cameraFlashMode controls the still-image flash when cameraCaptureMode is Photo. cameraFlashMode controls the video torch when cameraCaptureMode is Video.

 

@end

 

 

#pragma mark======== UIImagePickerControllerDelegate ====

 

 

__TVOS_PROHIBITED @protocol UIImagePickerControllerDelegate<NSObject>

@optional

// The picker does not dismiss(让…离开) itself; the client(用户) dismisses it in these callbacks(回调函数).

// The delegate will receive one or the other, but not both, depending whether the user

// confirms(确定) or cancels(取消).

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo NS_DEPRECATED_IOS(2_0, 3_0); //DEPRECATED

 

//点击Choose后的协议方法

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info;

 

//点击Cancel后的协议方法

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;

 

@end

 

 

#pragma mark======== Adds a photo to the saved photos album. ====

 

// Adds a photo to the saved photos album.  The optional completionSelector should have the form:

//  - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;

UIKIT_EXTERN void UIImageWriteToSavedPhotosAlbum(UIImage *image, __nullable id completionTarget, __nullable SEL completionSelector, void * __nullable contextInfo) __TVOS_PROHIBITED;

 

// Is a specific video eligible to be saved to the saved photos album? 

UIKIT_EXTERN BOOL UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(NSString *videoPath) NS_AVAILABLE_IOS(3_1) __TVOS_PROHIBITED;

 

 

 

#pragma mark======== Adds a video to the saved photos album. ====

 

// Adds a video to the saved photos album. The optional completionSelector should have the form:

//  - (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;

UIKIT_EXTERN void UISaveVideoAtPathToSavedPhotosAlbum(NSString *videoPath, __nullable id completionTarget, __nullable SEL completionSelector, void * __nullable contextInfo) NS_AVAILABLE_IOS(3_1) __TVOS_PROHIBITED;

 

NS_ASSUME_NONNULL_END

 

posted on 2016-11-08 23:44  dreamDeveloper  阅读(638)  评论(0编辑  收藏  举报

导航