美文网首页
2019-03-18

2019-03-18

作者: 瑷岚 | 来源:发表于2019-03-18 22:25 被阅读0次

    自我剖析:工作五年多,以项目为驱动,重复工作,缺少钻研精神。

    随手记录一些东西,偏向于源码的

    day 1 :ios UIImagePickerController 

    UIImagePickerController 继承UINavigationController,可通过init(navigationBarClass:AnyClass?, toolbarClass:AnyClass?)自定义导航栏

    open class func isSourceTypeAvailable(_ sourceType: UIImagePickerController.SourceType) -> Bool // returns YES if source is available (i.e. camera present) //判断类型是否有效

        open class func availableMediaTypes(for sourceType: UIImagePickerController.SourceType) -> [String]? // returns array of available media types (i.e. kUTTypeImage)//有效的类型

        @available(iOS 4.0, *)

        open class func isCameraDeviceAvailable(_cameraDevice:UIImagePickerController.CameraDevice) ->Bool// returns YES if camera device is available  //相机是否有效

        @available(iOS 4.0, *)

        open class func isFlashAvailable(for cameraDevice: UIImagePickerController.CameraDevice) -> Bool // returns YES if camera device supports flash and torch. //是否支持flash和torch

        @available(iOS 4.0, *)

        open class func availableCaptureModes(for cameraDevice: UIImagePickerController.CameraDevice) -> [NSNumber]? // returns array of NSNumbers (UIImagePickerControllerCameraCaptureMode) //

        weak open var delegate: (UIImagePickerControllerDelegate & UINavigationControllerDelegate)? //代理写法

        open var sourceType: UIImagePickerController.SourceType // default value is UIImagePickerControllerSourceTypePhotoLibrary.

        open var mediaTypes: [String]

        // default value is an array containing kUTTypeImage.

        @available(iOS 3.1, *)

        open var allowsEditing: Bool // replacement for -allowsImageEditing; default value is NO.

        @available(iOS 11.0, *)

        open var imageExportPreset: UIImagePickerController.ImageURLExportPreset // default value is UIImagePickerControllerImageExportPresetCompatible.

        // video properties apply only if mediaTypes includes kUTTypeMovie

        @available(iOS 3.1, *)

        open var videoMaximumDuration: TimeInterval // default value is 10 minutes.

        @available(iOS 3.1, *)

        open var videoQuality: UIImagePickerController.QualityType // default value is UIImagePickerControllerQualityTypeMedium. If the cameraDevice does not support the videoQuality, it will use the default value.

        @available(iOS 11.0, *)

        open var videoExportPreset: String // videoExportPreset can be used to specify the transcoding quality for videos (via a AVAssetExportPreset* string). If the value is nil (the default) then the transcodeQuality is determined by videoQuality instead. Not valid if the source type is UIImagePickerControllerSourceTypeCamera

        // camera additions available only if sourceType is UIImagePickerControllerSourceTypeCamera.

        @available(iOS 3.1, *)

        open var showsCameraControls: Bool // set to NO to hide all standard camera UI. default is YES

        @available(iOS 3.1, *)

        open var cameraOverlayView: UIView? // set a view to overlay the preview view.

        @available(iOS 3.1, *)

        open var cameraViewTransform: CGAffineTransform // set the transform of the preview view.

        @available(iOS 3.1, *)

        open func takePicture()

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

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

        @available(iOS 4.0, *)

        open func startVideoCapture() ->Bool

        @available(iOS 4.0, *)

        open func stopVideoCapture()

        @available(iOS 4.0, *)

        open var cameraCaptureMode: UIImagePickerController.CameraCaptureMode // default is UIImagePickerControllerCameraCaptureModePhoto

        @available(iOS 4.0, *)

        open var cameraDevice: UIImagePickerController.CameraDevice // default is UIImagePickerControllerCameraDeviceRear

        @available(iOS 4.0, *)

        open var cameraFlashMode: UIImagePickerController.CameraFlashMode // default is UIImagePickerControllerCameraFlashModeAuto. 

    enum SourceType :Int{

            case photoLibrary

            case camera

            case savedPhotosAlbum

        }

    enum QualityType :Int{

            case typeHigh// highest quality

            case typeMedium // medium quality, suitable for transmission via Wi-Fi 

            case typeLow // lowest quality, suitable for tranmission via cellular network

            @available(iOS4.0, *)

            case type640x480// VGA quality

            @available(iOS5.0, *)

            case typeIFrame1280x720

            @available(iOS5.0, *)

            case typeIFrame960x540

        }

    enum CameraCaptureMode :Int{

            case photo

            case video

        }

    enum CameraDevice :Int{

            case rear

            case front

        }

    enum CameraFlashMode :Int{

            case off

            case auto

            case on

        }

    enum ImageURLExportPreset :Int{//@available(iOS 11.0, *)

            case compatible

            case current

        }

    public struct InfoKey : Hashable, Equatable, RawRepresentable {

            publicinit(rawValue:String)

        }

    UIImagePickerController.InfoKey 

        public static let mediaType: UIImagePickerController.InfoKey

        public static let originalImage: UIImagePickerController.InfoKey // a UIImage

        public static let editedImage: UIImagePickerController.InfoKey // a UIImage

        public static let cropRect: UIImagePickerController.InfoKey // an NSValue (CGRect)

        public static let mediaURL: UIImagePickerController.InfoKey // an NSURL

        @available(iOS, introduced: 4.1, deprecated: 11.0, message: "Replace with public API: UIImagePickerControllerPHAsset")

        public static let referenceURL: UIImagePickerController.InfoKey // an NSURL that references an asset in the AssetsLibrary framework

        @available(iOS 4.1, *)

        public static let mediaMetadata: UIImagePickerController.InfoKey // an NSDictionary containing metadata from a captured photo

        @available(iOS 9.1, *)

        public static let livePhoto: UIImagePickerController.InfoKey // a PHLivePhoto

        @available(iOS 11.0, *)

        public static let phAsset: UIImagePickerController.InfoKey // a PHAsset

        @available(iOS 11.0, *)

        public static let imageURL: UIImagePickerController.InfoKey // an NSURL

    public protocol UIImagePickerControllerDelegate :NSObjectProtocol{

        @available(iOS 2.0, *)

        optional public func imagePickerController(_picker:UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey:Any])

        @available(iOS 2.0, *)

        optional public func imagePickerControllerDidCancel(_picker:UIImagePickerController)

    }

    // 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;

    //将照片添加到已保存的相册中,有时会crash。可以尝试下先将image转为png,再存储。而且图片不应过大,过大也会导致崩溃。

    public func UIImageWriteToSavedPhotosAlbum(_image:UIImage,_completionTarget:Any?,_completionSelector:Selector?,_contextInfo:UnsafeMutableRawPointer?)

    // Is a specific video eligible to be saved to the saved photos album? //视频是否可以保存

    @available(iOS 3.1, *)

    public func UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(_videoPath:String) ->Bool

    // 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;//将视频添加到已保存的相册中

    @available(iOS 3.1, *)

    public func UISaveVideoAtPathToSavedPhotosAlbum(_videoPath:String,_completionTarget:Any?,_completionSelector:Selector?,_contextInfo:UnsafeMutableRawPointer?)

    next:PHAsset

    相关文章

      网友评论

          本文标题:2019-03-18

          本文链接:https://www.haomeiwen.com/subject/ypeimqtx.html