简体   繁体   中英

FilePicker in iOS 9.3 Exception

Trying to implement file picker on a device that runs on iOS 9.3

The capabilities are ticked inside Entitlements.plist and the code works on simulated device running iOS 12.2. Also tried to simulate other devices running iOS 9.3 and the result is the same

using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Plugin.FilePicker;
using System.Diagnostics;

namespace CrossfileTest
{

    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private async void BrowseBtn_Clicked(object sender, EventArgs e)
        {
            try
            {
                var file = await CrossFilePicker.Current.PickFile();
                Debug.WriteLine("this file " + file.FileName);
            }
            catch(Exception ex)
            {
                Debug.WriteLine("it blew up! " + ex);
            }
        }
    }
}```

This is the exception I get on iOS 9.3:
  at CrossfileTest.MainPage.BrowseBtn_Clicked (System.Object sender, System.EventArgs e) [0x00029] in C:\Users\UserName\source\repos\CrossfileTest\CrossfileTest\CrossfileTest\MainPage.xaml.cs:27  0   CoreFoundation                      0x000000010bba4d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010c520deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010bba4bea +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010a7fcd5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
    4   UIKit                               0x00000001093485c5 -[UIDocumentPickerViewController _commonInitWithCompletion:] + 370
    5   UIKit                               0x000000010934a442 -[UIDocumentPickerViewController initWithDocumentTypes:inMode:] + 411
    6   CrossfileTest.iOS                   0x0000000102c25539 xamarin_dyn_objc_msgSend + 217
    7   ???                                 0x000000011f6039ee 0x0 + 4821367278

Ideas on how to fix this?

This is obviously the crash inside the plug-in. You may post the issue on their github in order to be fixed.

There is a difference in how UIDocumentPickerViewController works on iOS 9 and iOS 12, so there is nothing particularly strange if it works on one and not on another.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM