我在MonoTouch和iOS6模拟器以及iOS6设备上使用UIDocumentInteractionController,我的代码一半正常工作。但是它对于iOS5模拟器/设备根本不起作用。这是我在示例项目中进行测试的示例类。
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
namespace DocumentThing
{
public class MyViewController : UIViewController
{
UIDocumentInteractionController documentInteractionController1;
UIDocumentInteractionController documentInteractionController2;
UIBarButtonItem leftButton;
UIBarButtonItem rightButton;
public MyViewController()
{
}
public override void ViewDidLoad()
{
View.BackgroundColor = UIColor.White;
leftButton = new UIBarButtonItem(UIBarButtonSystemItem.Action, null, null);
leftButton.Clicked += delegate(object sender, EventArgs e)
{
InvokeOnMainThread(delegate {
documentInteractionController1 = new UIDocumentInteractionController();
documentInteractionController1.Url = NSUrl.FromFilename(@"testpdf.pdf");
documentInteractionController1.PresentOpenInMenu(View.Frame, View, true);
});
};
NavigationItem.LeftBarButtonItem = leftButton;
rightButton = new UIBarButtonItem(UIBarButtonSystemItem.Action, null, null);
rightButton.Clicked += delegate(object sender, EventArgs e)
{
InvokeOnMainThread(delegate {
documentInteractionController2 = new UIDocumentInteractionController();
documentInteractionController2.Url = NSUrl.FromFilename(@"testpdf.pdf");
documentInteractionController2.PresentOptionsMenu(View.Frame, View, true);
});
};
NavigationItem.RightBarButtonItem = rightButton;
}
}
}
PresentOptionsMenu在iOS6上工作正常但在iOS5中没有,iOS5和iOS6上的PresentOptionInMenu都失败了。不确定这是否是iOS5 / 6 SDK /模拟器的错误,或者是否是MonoTouch中的错误。我不知道如何进一步调试这个问题...
建议?
答案 0 :(得分:1)
回答我自己的问题......
您是否检查过您的设备上是否有打开PDF的东西?不要忘记默认情况下不安装iBooks,iOS不认为将Safari用作PDF阅读器。