Question

I am using UIDocumentInteractionController in MonoTouch and in the iOS6 Simulator and on iOS6 devices my code half works. However it does not work at all for iOS5 simulator/devices. Here is a sample class I made to test with in a sample project.

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;
        }
    }
}

The PresentOptionsMenu works fine on iOS6 but not in iOS5, and the PresentOptionInMenu fails on both iOS5 and iOS6. Not sure if this is a bug with iOS5/6 SDKs/Simulators or if it is a bug in MonoTouch. I got no idea how to debug this issue further...

Suggestions?

Was it helpful?

Solution

Answering my own question...

Did you check if you have any thing to open a PDF on your device which has iOS5 on it? Don't forget iBooks is not installed by default and iOS does not think to use Safari as a PDF reader.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top