0

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.

Community
  • 1
  • 1
Sumeet Purohit
  • 657
  • 1
  • 7
  • 16
  • To do this you need to swizzle the AlertController's present method and then present your own, forward the user input to the original alert. I wouldn't prefer this anyway. – Sachin Vas Feb 15 '17 at 08:10
  • Could you please elaborate in more detail how I should go coz I'm new in swift. – Sumeet Purohit Feb 15 '17 at 08:13
  • It is more elaborated thing to do. It requires lot of time to explain and I am unsure if this works or not as well. Also, people don't prefer this way. – Sachin Vas Feb 15 '17 at 08:19

2 Answers2

1

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.

AtaerCaner
  • 691
  • 7
  • 12
0

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

Anand Nimje
  • 6,163
  • 4
  • 24
  • 43