gpt4 book ai didi

xamarin.ios - 如何以非模态方式使用 QLPreviewController?为什么我的代码不起作用?

转载 作者:行者123 更新时间:2023-12-02 00:34:54 25 4
gpt4 key购买 nike

我已启动并运行 QLPreviewController,但我正在使用 PresentModalViewController() 直接显示 QLPreviewController。出于无法解释的原因,我想拥有自己的 UIViewController,它将创建自己的 View ,并且在该 View 中我想使用 QLPreviewController。我想应该很容易,但是下面的代码什么也没做。 QLPreviewControllers ViewDidAppear 永远不会被调用。 (在我下面的示例中,PreviewController 继承自 QLPreviewController 并封装了 delegate、preview item 和 source)。有人可以解释下面的代码有什么问题吗(除了毫无意义的事实:-))?哦,是的:在我的测试场景中,我在下面模态地展示了 Controller 。它显示但没有预览。

 public class OuterPreviewController : UIViewController
{
public OuterPreviewController (QLPreviewControllerDataSource oDataSource) : base()
{
this.oDataSource = oDataSource;
}

private PreviewController oPreviewController;
private QLPreviewControllerDataSource oDataSource;

public override void LoadView ()
{
this.View = new UIView();
this.View.Frame = new RectangleF(0, 0, 500, 500);
this.View.BackgroundColor = UIColor.Red;

}

public override void ViewDidAppear (bool animated)
{
// Code execution comes her. No errors, no issues.
base.ViewDidAppear (animated);
this.oPreviewController = new PreviewController();
this.oPreviewController.DataSource = this.oDataSource;
// Preview controller's view is added but it never shows up.
this.View.AddSubview(this.oPreviewController.View);
this.oPreviewController.View.Frame = this.View.Frame;
this.oPreviewController.View.Center = this.View.Center;
}

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
return true;
}
}

最佳答案

今天偶然发现了一个解决方案:预览 Controller 上的所有 ReloadData() 都神奇地显示了它的内容。

这允许将 QLPreviewController 作为 subview 添加到现有 View 并嵌入预览。它还可以让您摆脱包含打开方式菜单的工具栏。

关于xamarin.ios - 如何以非模态方式使用 QLPreviewController?为什么我的代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5054195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com