为什么我无法在菜单中看到我想念的打印选项
private void OpenExtrnal()
{
Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
{
UIView parentView = UIApplication.SharedApplication.KeyWindow.RootViewController.View;
CGRect buttonFrame = new CGRect( 0 , -260 , 320 , 320);
var PreviewController = UIDocumentInteractionController.FromUrl(new NSUrl(localDocUrl, true));
PreviewController.Delegate = new UIDocumentInteractionControllerDelegateClass(UIApplication.SharedApplication.KeyWindow.RootViewController);
if(passedImage != null && Device.Idiom == TargetIdiom.Tablet){
buttonFrame = FormsViewToNativeiOS.ConvertFormsToNative(passedImage).Frame;
}
PreviewController.PresentOpenInMenu(buttonFrame , parentView , true);
});
}
委托班级
public class UIDocumentInteractionControllerDelegateClass : UIDocumentInteractionControllerDelegate
{
UIViewController viewC;
public UIDocumentInteractionControllerDelegateClass(UIViewController controller)
{
viewC = controller;
}
public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller)
{
return viewC;
}
public override UIView ViewForPreview(UIDocumentInteractionController controller)
{
return viewC.View;
}
}
答案 0 :(得分:1)
您必须使用PreviewController.PresentOptionsMenu
代替PreviewController.PresentOpenInMenu
来显示“打印”等选项。
PresentOpenInMenu
和PresentOptionsMenu
之间的区别在于:
- 要向用户提示一组选项,包括在其他应用中打开文件的选项,请调用
presentOptionsMenuFromRect:inView:animated:
或presentOptionsMenuFromBarButtonItem:animated:
方法。- 要提示用户仅在其他应用中打开该文件,请调用
presentOpenInMenuFromRect:inView:animated:
或presentOpenInMenuFromBarButtonItem:animated:
方法。
请参阅Apple文档:GrantPermissionRule。