2015-03-25 48 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]; 
}