在使用self.imagePicker.mediaTypes = [(kUTTypeImage as String)]through 时,UIImagePicker我可以选择所有类型的图像,但我的要求是仅JPG, JPEG and PNG通过照片库选择类型图像,GIF并且HEIC不允许使用和(实时照片)。
那么,有什么方法可以阻止我选择GIF和HEIC类型的照片,同时imagePicker.sourceType = .photoLibrary
代码:
imagePicker.delegate = self
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: StringConstants.Actions.Camera, style: .default, handler: { (action:UIAlertAction) in
CheckPermissions.checkPermission(permissionFor: .Camera,vc:self) { (success) in
if success {
DispatchQueue.main.async {[unowned self] in
if(UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera)) {
self.view.endEditing(true)
self.imagePicker.allowsEditing = false
self.imagePicker.sourceType = UIImagePickerControllerSourceType.camera
self.imagePicker.cameraCaptureMode = .photo
self.imagePicker.showsCameraControls = true
self.imagePicker.modalPresentationStyle = .overFullScreen
self.present(self.imagePicker, animated: …Run Code Online (Sandbox Code Playgroud)