2012-08-01 42 views
2

所以我使用WEPopover來顯示自定義視圖控制器彈出。我有一個UIView,裏面有另一個叫做containerView的UIView。在這個containerView裏面,我有一個UIButton。這是我想要展示我的popover的地方。因此,這裏是我所做的:presentPopoverFromRect從一個按鈕超出界限

[self.popoverDialog presentPopoverFromRect:sender.frame inView:self.containerView permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; 

的問題是,箭頭,一切都從這個按鈕有顯示,但是酥料餅熄滅self.containerView界。我怎樣才能讓彈出窗口顯示在containerView邊界內?

編輯:

一張圖片勝過一千字,所以在這裏它是: 淺灰色的是我上述containerView。從理論上說,這個popover應該顯示在那個淺灰色範圍內,不會出現在外面。

enter image description here

回答

0

對於包含在裏面酥料餅的觀點,去它的視圖控制器,並設置其屬性contentSizeForViewInPopover。在這裏,您可以設置大小以適合containerView的邊界。

OP想定位彈出窗口,以便它只顯示在他的容器視圖中。我發現在WEPopoverController.m該位的代碼文件

- (void)repositionPopoverFromRect:(CGRect)rect 
         inView:(UIView *)theView 
    permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections { 

CGRect displayArea = [self displayAreaForView:theView]; 
WEPopoverContainerView *containerView = (WEPopoverContainerView *)self.view; 
[containerView updatePositionWithAnchorRect:rect 
           displayArea:displayArea 
        permittedArrowDirections:arrowDirections]; 

popoverArrowDirection = containerView.arrowDirection; 
containerView.frame = [theView convertRect:containerView.frame toView:backgroundView]; 

}

你可能調用此方法,因此它現在是你的容器內VIW它可能重新定位你的酥料餅。

+0

我已經這樣做了..尺寸很好..但只是想保持它的大小,這樣它不會超出界限 – adit 2012-08-02 14:30:41

+0

你能提供一個圖像嗎?我無法理解你的意思是出界。它仍然完全在屏幕內嗎? – 2012-08-02 14:53:16

+0

我添加了一張圖片 – adit 2012-08-02 16:40:42