Home iOS 11 application crashes when trying to add attachment from camera
Reply: 1

iOS 11 application crashes when trying to add attachment from camera

rosstripi Published in 2017-11-14 20:17:27Z

I have an application that crashes when the user tries to add an attachment from the camera (however it doesn't crash when they opt to load the attachment from their Photo Library).

Here's the method that gets called when an option (either Camera or Photo Library) is selected:

    public void AddMedia(UIImagePickerControllerSourceType type)
        _imagePicker = new UIImagePickerController();

        // set our source to the photo library
        _imagePicker.SourceType = type;

        // set what media types
        _imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(type);

        _imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;

        _imagePicker.Canceled += (sender, evt) =>
            Console.WriteLine("picker cancelled");
            _imagePicker.DismissViewController(false, () =>

        //PresentModalViewController is depreciated in iOS6 so we use PresentViewController
        Parent.PresentViewController(_imagePicker, true, null);

And this is the line where it crashes:

        _imagePicker.SourceType = type;

Why would it crash when setting it to Camera but not Photo Library? Does it have something to do with how the enum is ordered (Photo Library = 0, Camera = 1, Saved Photos Album = 2)?

Taier Reply to 2017-11-14 21:01:01Z

Are you trying to reproduce it on simulator? Because you don't have an access to camera on it.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.330035 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO