I am using Xamarin monotouch c# for an iphone app showing PDF documents.
My problem is that I get a black screen when exiting a PDF in the UIDocumentInteractionController after i upgraded to iOS 7.
In the source constructor I make a new DocController:
this.DocumentPreview = new UIDocumentInteractionController();
this.DocumentPreview.Delegate = new DocumentInteractionDelegate(this.DidEndPreview);
When I select a row I get the PDF and show it (working):
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
// Get PDF url from indexpath
...
// Set url
this.DocumentPreview.Url = url;
this.DocumentPreview.PresentPreview(true);
// Here i get a warning : Presenting view controllers on detached view controllers is discouraged
}
This is my DocControllerDelegate class presenting the preview in my workspace:
public class DocumentInteractionDelegate : UIDocumentInteractionControllerDelegate
{
private Action DidEnd;
public DocumentInteractionDelegate(Action didEnd)
{
this.DidEnd = didEnd;
}
public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller)
{
return AppDelegate.Instance.Workspace;
}
public override void DidEndPreview(UIDocumentInteractionController controller)
{
this.DidEnd.Execute();
}
}
The DidEnd action is not significant since the black screen is already there when the action triggers.
And yes I have set a root controller:
this.MainWindow.RootViewController = this.MainViewController;
I don't know if the warning was there in iOS6 but i could come back from my PDF just fine and select another one in my table to show and now in iOS7 I get a black screen when clicking on Done in the PDF.
How can I get back to my controller without a black screen and what changes in iOS7 affected this behaviour?
Thank you
EDIT
I have managed to get rid of the warning Presenting view controllers on detached view controllers is discouraged on Workspace with this:
this.MainViewController.AddChildViewController(this.Workspace);
but I still get to the black screen on dismissing the PDF.