Sumeet Purohit
Sumeet Purohit

Reputation: 667

Show custom alert for camera and gallery permission swift 3

May be this is duplicate question but I actually didn't find exact solution. I have camera and photo gallery collection view on the same screen.see this UI

When I land to this screen, I get two alerts: one for camera access and other for photo access. Can anyone tell me how to get rid of these native alerts and implement the custom one alert for both the permissions.

Upvotes: 0

Views: 2698

Answers (2)

AtaerCaner
AtaerCaner

Reputation: 712

You can get the image when picking is done with imagePickerController

First, implement the UIImagePickerControllerDelegate

Second, create an instance and set the delegate

let imagePicker = UIImagePickerController()
imagePicker.delegate = self

Present the imagePicker with

present(imagePicker, animated: true, completion: nil)

And finally

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let image = info[UIImagePickerControllerOriginalImage] as! UIImage
        imagePicker.dismiss(animated: true, completion: nil)
    }

Now you have the image.

Upvotes: 1

Anand Nimje
Anand Nimje

Reputation: 6251

Whenever you will be add permission details inside your applications <Your App Name>.plist. App will automatically show default alert message from your .plist privacy permissions String displaying there because permission message always display in default alert view so you can do one thing before access camera show yours custom alert then redirect to camera/gallery view.

permission

Before accessing camera you can show like this(Example contain only)

enter image description here

Upvotes: 0

Related Questions