Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios 在iOS Xamarin中上载文件_Xamarin.ios - Fatal编程技术网

Xamarin.ios 在iOS Xamarin中上载文件

Xamarin.ios 在iOS Xamarin中上载文件,xamarin.ios,Xamarin.ios,我一直在尝试从文件系统上传PDF文件。 在iOS模拟器中工作良好,而在iOS设备中则不工作。 “UIFileSharingEnabled”在info.plist中设置为“True”。 下面是代码…我有什么遗漏吗 ================== var docPicker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Open); docPicker.DidPick

我一直在尝试从文件系统上传PDF文件。 在iOS模拟器中工作良好,而在iOS设备中则不工作。 “UIFileSharingEnabled”在info.plist中设置为“True”。 下面是代码…我有什么遗漏吗

==================

        var docPicker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Open);
        docPicker.DidPickDocumentAtUrls += (object sender, UIDocumentPickedAtUrlsEventArgs e) =>
        {
            var filename = Path.Combine(e.Urls[0].LastPathComponent);
            string msg1 = string.Format("Successfully imported file '{0}'", filename);
            string msg2  = string.Format("Failed to import file '{0}'", filename);

            NSData data = NSData.FromUrl(e.Urls[0]);

            if (data != null)
            {
                byte[] dataBytes = new byte[data.Length];
                ViewModel.PDFBytes = dataBytes;
                Console.WriteLine(data + "Completed");

                var alertController = UIAlertController.Create("import", msg1, UIAlertControllerStyle.Alert);
                var okButton = UIAlertAction.Create("OK", UIAlertActionStyle.Default, (obj) =>
                {
                    alertController.DismissViewController(true, null);
                });
                alertController.AddAction(okButton);
                PresentViewController(alertController, true, null);
            }
            else
            {
                var alertController = UIAlertController.Create("import", msg2, UIAlertControllerStyle.Alert);
                var okButton = UIAlertAction.Create("OK", UIAlertActionStyle.Default, (obj) =>
                {
                    alertController.DismissViewController(true, null);
                });
                alertController.AddAction(okButton);
                PresentViewController(alertController, true, null);
            }
        };
        PresentViewController(docPicker, true, null);

尝试更改第一行:

var docPicker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Open);
致:

请查看此链接以获取信息:
尝试更改第一行:

var docPicker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Open);
致:

请查看此链接以获取信息: