2013-08-21 53 views
1

我的通用应用程序使用NIB作为其设置屏幕。我想为iPhone和iPad使用相同的NIB。UIPopoverController内部移位框架

因此,在iPad上,我使用MainViewController中的UIPopoverController进行设置,只显示iPhone大小的NIB,以显示所谓的SettingsViewController。弹出窗口大小为320x460点。

这会导致一个问题,因为iPhone版本以编程方式在状态栏上方绘制了许多东西,而对于iPad版本,这不是必需的。 iPad上的现状:

enter image description here

正如你所看到的,有上述的“设置”标题一大空白。因此,我想要的,是将视图控制器约20分,上移的酥料饼内:

enter image description here

的酥料饼如MainViewController如下实例:

 settingsPopoverController = [[UIPopoverController alloc] initWithContentViewController:popoverNavigationController]; 
     settingsPopoverController.popoverContentSize = CGSizeMake(320, 460); 
     settingsPopoverController.delegate = self; 
     popoverNavigationController.navigationBarHidden = YES; 

在SettingsViewController,我设置框架如下:

- (void)viewDidLoad 
{ 
    self.contentSizeForViewInPopover = CGSizeMake(320, 460); 
} 

而后来在Settin gsViewController,我尝试创建一个偏移量,如下所示:

- (void)viewWillLayoutSubviews 
{ 
    // shift it up 
    CGRect frame = self.view.frame; 
    frame.origin.y = -20; 
    [self.view setFrame:frame]; 
} 

这不会将内容向上移动一点。怎么去?

澄清:我想下移popover显示的“视口”。

回答

-1

尝试:

myPopover.autoresizingMask=UIViewAutoresizingNone; 

或者:

myPopover.autoresizingMask=UIViewAutoresizingFlexibleHeight || UIViewAutoresizingFlexibleWidth; 

您也可以尝试把你的代码-(void)viewDidLayoutSubviews方法。 如果这个答案没有帮助,尽量设置popoverLayoutMargins(属性),而不是setFrame:例如:

popover.popoverLayoutMargins=UIEdgeInsetsMake (
CGFloat 50, //top 
CGFloat 50,//left 
CGFloat 50,//bottom 
CGFloat 50//right 
); 
+1

UIPopoverController没有autoresizingMask属性,不知道你的意思。 将代码移动到viewDidLayoutSubview没有任何影响。 –

+0

在IB尝试将偏移约束的优先级设置为最小值。 – Kepler

+0

您是否需要移动弹出窗口视图或弹出窗口箭头? – Kepler