En utilisant self.imagePicker.mediaTypes = [(kUTTypeImage as String)]
par le biais de UIImagePicker
Je suis en mesure de sélectionner tous les types d'images, mais mon besoin est de sélectionner uniquement les images. JPG, JPEG and PNG
taper des images dans la photothèque et GIF
y HEIC
(photos en direct) ne sont pas autorisées.
Alors, y a-t-il un moyen d'éviter de sélectionner GIFs y HEIC photo de type alors que imagePicker.sourceType = .photoLibrary
Code :
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: true, completion: nil)
}
else {
self.showAlert(withTitle: kEmptyString, message: StringConstants.AlertMessage.cameraAlertMessage, andOkAction: nil )
}
}
}
}
}))
actionSheet.addAction(UIAlertAction(title: StringConstants.Actions.PhotoLibrary, style: .default, handler: { (action:UIAlertAction) in
CheckPermissions.checkPermission(permissionFor: .PhotoLibrary,vc: self) { (success) in
if success {
DispatchQueue.main.async {[unowned self] in
self.view.endEditing(true)
self.imagePicker.allowsEditing = false
self.imagePicker.sourceType = .photoLibrary
self.imagePicker.modalPresentationStyle = .overFullScreen
self.imagePicker.navigationBar.isTranslucent = false
self.imagePicker.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
self.present(self.imagePicker, animated: true, completion: nil)
}
}
}
}))