Swift - iOS 照片選取和拍照

jopen 9年前發布 | 23K 次閱讀 IOS iOS開發 移動開發

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.baiduhome.net/lib/view/home/1446476299310

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!