我在 MonoTouch 和 iOS6 模拟器中使用 UIDocumentInteractionController,在 iOS6 设备上,我的代码可以正常工作。但是它根本不适用于 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 上不行,PresentOptionInMenu 在 iOS5 和 iOS6 上都失败。不确定这是 iOS5/6 SDKs/模拟器的错误还是 MonoTouch 中的错误。我不知道如何进一步调试这个问题......
建议?