iOS 9.3异常中的FilePicker

问题描述 投票:0回答:1

试图在运行iOS 9.3的设备上实现文件选择器

功能在Entitlements.plist中打勾,并且代码在运行iOS 12.2的模拟设备上运行。还尝试模拟其他运行iOS 9.3的设备,结果是相同的

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?
c# xamarin xamarin.ios ios9.3
1个回答
0
投票

这显然是插件内部的崩溃。您可以将问题发布在他们的github上以进行修复。

UIDocumentPickerViewController在iOS 9和iOS 12上的工作方式有所不同,因此如果仅在一个而不是另一个上工作就没有什么特别奇怪的。

© www.soinside.com 2019 - 2024. All rights reserved.