【问题标题】:UIPresentationController - presentation view size?UIPresentationController - 演示视图大小?
【发布时间】:2015-03-25 02:36:11
【问题描述】:

我正在使用 UIPresentationController,但我不知道如何让它显示我想要的方式。

我正在编辑frameOfPresentedViewInContainerView() 函数,我需要返回框架(CGRect)来显示我的内容。

我遵循的教程使用CGRectInsert(self.containerView.bounds, 50, 50),它使窗口居中,边框为50px。如果我返回 self.containerView.bounds 本身,则视图会占据整个屏幕。

我希望覆盖视图是父视图的宽度(所以,self.containerView.bounds.width),但我希望高度是显示新视图内容所需的大小,而不会切断任何内容。

我在 (0,0) 处尝试了一个宽度和高度来自 self.preferredContentSize 的 CGRect,但它没有返回有效的尺寸。我该怎么办?

我尝试frame = CGRect(x:0, y: self.containerView.bounds.height/2, width: self.containerView.bounds.width, height: self.containerView.bounds.height/2) 只是作为测试(但这只是使视图大小是父视图的一半),但是当我旋转屏幕时,突然新视图几乎不在屏幕上..

【问题讨论】:

  • 你是怎么解决这个问题的?
  • 我不相信我曾经做过 - 我想我只是找到了一个完全不同的解决方案。

标签: ios xcode swift


【解决方案1】:

除了frameOfPresentedViewInContainerView(),我还必须添加以下内容才能使其正常工作。

- (void)containerViewWillLayoutSubviews
{
    self.presentedView.frame = [self frameOfPresentedViewInContainerView];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-07
    • 2015-07-23
    • 1970-01-01
    • 2015-06-18
    • 2021-01-03
    • 1970-01-01
    • 2013-05-07
    相关资源
    最近更新 更多