I use the UIDocumentInteractionController to preview files of different types within the app. This has worked fine in the past, but when running the app on a device with iOS 13 the document is not presented. What is shown is the file name and type.
I have looked for similar questions and found this UIDocumentInteractionController showing file name and file type , not file contents
I've tried NSUrl.CreateFileUrl(FilePath, null)
as the comments on that question suggest but this doesn't solve the issue.
This is what I use for opening the file and presenting the preview:
var uidic = UIDocumentInteractionController.FromUrl(new NSUrl(FilePath, true));
uidic.Delegate = new DocInteractionC(navcontroller);
uidic.PresentPreview(true);
And the controller definition:
public class DocInteractionC : UIDocumentInteractionControllerDelegate
{
readonly UIViewController m_oParentViewController;
public DocInteractionC(UIViewController controller)
{
m_oParentViewController = controller;
}
public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller)
{
return m_oParentViewController;
}
public override UIView ViewForPreview(UIDocumentInteractionController controller)
{
return m_oParentViewController.View;
}
}
Is it possible this is an issue with NSUrl in Xamarin.ios for iOS 13? Any help would be much appreciated.
My issue was solved by modifying the code as followed:
var uidic = new UIDocumentInteractionController()
{
Name = fileName,
Url = NSUrl.FromFilename(filePath),
Delegate = new DocInteractionC(viewController)
};
uidic.PresentPreview(true);
Larger files, like an 11MB XLSX file, will take very long to load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With