2012-04-15 93 views
0

我在加載彈出窗口的MainViewController上添加了UIButton。即使添加按鈕位於最右邊,我希望彈出窗口在加載時居中。 iPad應用程序(iOS 5.1)的唯一視圖將成爲風景。我刪除了方向箭頭。控制彈出窗口的位置

我試過@property(nonatomic,readwrite)UIEdgeInsets popoverLayoutMargins;但我無法弄清楚如何使用它進行編碼。

我也遇到過沒有運氣的presentPopoverFromRect:CGRectMake(x,y,w,h)]。

如有必要,我可以包含代碼。

謝謝你的幫助。

回答

0

以下代碼將屏幕頂部x軸上的彈出窗口居中。如果您還想將其居中在y軸上,請使用self.view.frame.height/2作爲CGRectMake中的第二個參數。

[_myPopover presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2 ,0,1,1) 
            inView:self.view 
        permittedArrowDirections:UIPopoverArrowDirectionAny 
            animated:YES];