2015-03-25 34 views
3

我正在使用UIPresentationController,但我无法理清如何让它显示我想要的方式。UIPresentationController - 演示视图大小?

我编辑的frameOfPresentedViewInContainerView()功能,我需要返回框架(一的CGRect),以显示我的内容。

我跟着教程使用CGRectInsert(self.containerView.bounds, 50, 50),这使得与所带来的边界为中心的窗口在50px。如果我自己返回self.containerView.bounds,则视图会占据整个屏幕。

我想覆盖视图是父视图的宽度(so,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)只是作为测试(但这只是使视图的父视图的一半大小),但是当我旋转屏幕,突然的新观点几乎是关闭屏幕..

+0

您是如何解决这个问题的? – tombardey 2017-12-19 19:26:50

+0

我不相信我曾经做过 - 我想我只是找到了一个完全不同的解决方案。 – Max 2018-01-24 16:35:06

回答

0

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

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