Skip to content

Instantly share code, notes, and snippets.

@rafaelrmou
Created May 20, 2016 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrmou/1e7d83dbae3af57874df2cf779aaef37 to your computer and use it in GitHub Desktop.
Save rafaelrmou/1e7d83dbae3af57874df2cf779aaef37 to your computer and use it in GitHub Desktop.
public void DidPickDocumentPicker (UIDocumentMenuViewController documentMenu, UIDocumentPickerViewController documentPicker)
{
documentPicker.DidPickDocument += DocumentPicker_DidPickDocument;
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (documentPicker, true, null);
}
void DocumentPicker_DidPickDocument (object sender, UIDocumentPickedEventArgs e)
{
var securityEnabled = e.Url.StartAccessingSecurityScopedResource ();
System.Diagnostics.Debug.WriteLine (e.Url);
var doc = new UIDocument (e.Url);
}
public void Dispose ()
{
}
public async Task<byte[]> GetByteFile ()
{
var allowedUTIs = new string[] {
UTType.UTF8PlainText,
UTType.PlainText,
UTType.RTF,
UTType.PNG,
UTType.Text,
UTType.PDF,
UTType.Image,
UTType.UTF16PlainText,
UTType.FileURL
};
UIDocumentMenuViewController importMenu =
new UIDocumentMenuViewController (allowedUTIs, UIDocumentPickerMode.Import);
importMenu.Delegate = this;
importMenu.ModalPresentationStyle = UIModalPresentationStyle.Popover;
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (importMenu, true, null);
UIPopoverPresentationController presPopover = importMenu.PopoverPresentationController;
if (presPopover != null) {
presPopover.SourceView = UIApplication.SharedApplication.KeyWindow.RootViewController.View;
presPopover.PermittedArrowDirections = UIPopoverArrowDirection.Down;
// presPopover.SourceRect = ((UIButton)s).Frame;
}
return new byte[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment