• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

c# - 在 iOS 7 中退出 UIDocumentInteractionController 的 PDF 时出现黑屏

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:12:03 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在将 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 Action 并不重要,因为当 Action 触发时黑屏已经存在。

是的,我已经设置了一个根 Controller :

this.MainWindow.RootViewController = this.MainViewController;

我不知道 iOS6 中是否存在警告,但我可以很好地从我的 PDF 中返回并在我的表格中选择另一个要显示的内容,现在在 iOS7 中,单击 完成时出现黑屏 在 PDF 中。

如何在没有黑屏的情况下返回我的 Controller ?iOS7 中的哪些变化影响了这种行为?

谢谢

编辑

我已经设法摆脱了警告在工作区不鼓励在分离的 View Controller 上显示 View Controller :

this.MainViewController.AddChildViewController(this.Workspace); 

但我在关闭 PDF 时仍会出现黑屏。



Best Answer-推荐答案


这就是我在 UIDocumentInteractionControllerDelegate 中调用的内容:

它将关闭该文档预览窗口并允许您返回到之前的 View Controller 。

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

尝试将您的文档交互 Controller 委托(delegate)代码修改为:

public override UIViewController ViewControllerForPreview (UIDocumentInteractionController controller)
{

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

关于c# - 在 iOS 7 中退出 UIDocumentInteractionController 的 PDF 时出现黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19146955/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap