尝试从相机添加附件时,iOS 11应用程序崩溃

时间:2017-11-14 20:17:27

标签: ios xamarin xamarin.ios ios11 ios11.1.1

我有一个应用程序在用户尝试从相机添加附件时崩溃(但是当他们选择从照片库加载附件时它不会崩溃)。

以下是选择选项(相机或照片库)时调用的方法:

    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);
    }

这就是它崩溃的路线:

        _imagePicker.SourceType = type;

为什么在将其设置为相机而不是照片库时会崩溃?它与enum的排序方式有关(Photo Library = 0,Camera = 1,Saved Photos Album = 2)?

1 个答案:

答案 0 :(得分:1)

您是否尝试在模拟器上重现它?因为您无法访问相机。