Xamarin.ios 在iOS Xamarin中上载文件
我一直在尝试从文件系统上传PDF文件。 在iOS模拟器中工作良好,而在iOS设备中则不工作。 “UIFileSharingEnabled”在info.plist中设置为“True”。 下面是代码…我有什么遗漏吗 ==================Xamarin.ios 在iOS Xamarin中上载文件,xamarin.ios,Xamarin.ios,我一直在尝试从文件系统上传PDF文件。 在iOS模拟器中工作良好,而在iOS设备中则不工作。 “UIFileSharingEnabled”在info.plist中设置为“True”。 下面是代码…我有什么遗漏吗 ================== var docPicker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Open); docPicker.DidPick
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);
致:
请查看此链接以获取信息: