Created
May 20, 2016 17:33
-
-
Save rafaelrmou/1e7d83dbae3af57874df2cf779aaef37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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