[英]Black screen when exiting PDF of UIDocumentInteractionController in iOS 7
I am using Xamarin monotouch c# for an iphone app showing PDF documents. 我正在将Xamarin monotouch c#用于显示PDF文档的iPhone应用程序。
My problem is that I get a black screen when exiting a PDF in the UIDocumentInteractionController after i upgraded to iOS 7. 我的问题是,升级到iOS 7后,在UIDocumentInteractionController中退出PDF时出现黑屏。
In the source constructor I make a new DocController: 在源构造函数中,我制作了一个新的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): 当我选择一行时,我得到PDF并显示(工作):
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: 这是我的DocControllerDelegate类,在我的工作区中显示预览:
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. DidEnd操作并不重要,因为触发操作时黑屏已经存在。
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. 我不知道警告在iOS6中是否存在,但是我可以从PDF中回来,然后在表中选择另一个警告来显示,现在在iOS7中,单击PDF中的“完成”时出现黑屏。
How can I get back to my controller without a black screen and what changes in iOS7 affected this behaviour? 如何在没有黑屏的情况下返回控制器,iOS7中的哪些更改影响了此行为?
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: 我设法摆脱了警告, 因此不建议在Workspace上呈现分离视图控制器上的视图控制器 :
this.MainViewController.AddChildViewController(this.Workspace);
but I still get to the black screen on dismissing the PDF. 但我在关闭PDF时仍然遇到黑屏。
This is what I call in my UIDocumentInteractionControllerDelegate: 这就是我在UIDocumentInteractionControllerDelegate中所调用的:
It will close that Document Preview window and allow you back to your previous view controller. 它将关闭“文档预览”窗口,并允许您返回到以前的视图控制器。
UIApplication.SharedApplication.Windows [0].RootViewController.DismissViewController (true,null);
Try modding your Document Interaction Controller Delegate code to this : 尝试将您的Document Interaction Controller委托代码修改为此:
public override UIViewController ViewControllerForPreview (UIDocumentInteractionController controller)
{
return UIApplication.SharedApplication.Windows[0].RootViewController;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.