Swift - iOS 照片选取和拍照

jopen 5年前

HImagePickerUtils-Swift

 Swift - iOS 照片选取和拍照

使用:

weak var weakSelf = self

imagePicker = HImagePickerUtils()// HImagePickerUtils 对象必须为全局变量,不然UIImagePickerController代理方法不会执行

imagePicker.pickPhotoEnd = {a,b,c in    if b == HTakeStatus.Success {        imageView.image = a    }else{        let alert = UIAlertController(title: "Info", message: c, preferredStyle: UIAlertControllerStyle.Alert)        let action = UIAlertAction(title: "好的", style: UIAlertActionStyle.Default, handler: nil)        alert.addAction(action)        weakSelf?.presentViewController(alert, animated: true, completion: nil)    }    }

从相册取:

imagePicker.choosePhoto(self)

拍一张:

imagePicker.takePhoto(self)

项目主页:http://www.open-open.com/lib/view/home/1446476299310