簡體   English   中英

在iOS 7中退出UIDocumentInteractionController PDF時出現黑屏

[英]Black screen when exiting PDF of UIDocumentInteractionController in iOS 7

我正在將Xamarin monotouch c#用於顯示PDF文檔的iPhone應用程序。

我的問題是,升級到iOS 7后,在UIDocumentInteractionController中退出PDF時出現黑屏。

在源構造函數中,我制作了一個新的DocController:

this.DocumentPreview = new UIDocumentInteractionController();
this.DocumentPreview.Delegate = new DocumentInteractionDelegate(this.DidEndPreview);

當我選擇一行時,我得到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
}

這是我的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();
    }
}

DidEnd操作並不重要,因為觸發操作時黑屏已經存在。

是的,我已經設置了根控制器:

this.MainWindow.RootViewController = this.MainViewController;

我不知道警告在iOS6中是否存在,但是我可以從PDF中回來,然后在表中選擇另一個警告來顯示,現在在iOS7中,單擊PDF中的“完成”時出現黑屏。

如何在沒有黑屏的情況下返回控制器,iOS7中的哪些更改影響了此行為?

謝謝

編輯

我設法擺脫了警告, 因此不建議在Workspace上呈現分離視圖控制器上的視圖控制器

this.MainViewController.AddChildViewController(this.Workspace); 

但我在關閉PDF時仍然遇到黑屏。

這就是我在UIDocumentInteractionControllerDelegate中所調用的:

它將關閉“文檔預覽”窗口,並允許您返回到以前的視圖控制器。

UIApplication.SharedApplication.Windows [0].RootViewController.DismissViewController (true,null);

嘗試將您的Document Interaction Controller委托代碼修改為此:

public override UIViewController ViewControllerForPreview (UIDocumentInteractionController controller)
{

    return UIApplication.SharedApplication.Windows[0].RootViewController;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM