2011-09-22 134 views
0

我使用PresentPopOverFromRect方法呈现UIPopovercontroller。在肖像方向。当我自动旋转到横向UIPopoverController没有出现在适当的位置。如何在自动旋转设备时定位UIPopoverController。自动旋转UIPopOverController问题

+0

显示您调用presentPopoverFromRect的代码。在shouldAutorotateToInterfaceOrientation中,所有视图控制器都返回YES吗? – Anna

+0

@AnnaKarenina:是的 – user691106

回答

0

你需要重写此函数:

- (void)willAnimateRotationToInterfaceOrientation: 
(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 

在那里你可以改变这取决于您的当前方位的UIPopovercontroller的尺寸和位置。这个函数很方便,因为它在屏幕重绘之前和用户界面开始旋转之前被调用。

您应该检查此tutorial了解如何处理iPad不同方向的布局。

0

是的,作为tiguero说,在自定义的UIViewController,您可以覆盖的方法:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
    [self.popOverViewController dismissPopoverAnimated:NO]; 
    CGRect yourNewRect = CGRectMake(0.0, 0.0, 20, 20); 
    [self.popOverViewController presentPopoverFromRect:yourNewRect inView:yourView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
} 

你可以试试!