【问题标题】:UIPopOverController issues while autorotation自动旋转时出现 UIPopOverController 问题
【发布时间】:2011-09-22 09:46:29
【问题描述】:

我正在使用 PresentPopOverFromRect: 方法展示一个 UIPopovercontroller。在纵向。当我自动旋转到横向时,UIPopoverController 没有出现在正确的位置。如何在自动旋转设备时定位 UIPopoverController。

【问题讨论】:

  • 显示调用 presentPopoverFromRect 的代码。是否所有视图控制器在 shouldAutorotateToInterfaceOrientation 中都返回 YES?

标签: uipopovercontroller


【解决方案1】:

你需要重写这个函数:

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

您可以根据当前方向更改 UIPopovercontroller 的尺寸和位置。这个函数很方便,因为它在屏幕被重绘之前和用户界面开始旋转之前被调用。

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

【讨论】:

    【解决方案2】:

    是的,正如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];
    }
    

    你可以试试!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-27
      • 2020-05-10
      • 2011-05-11
      • 1970-01-01
      • 1970-01-01
      • 2021-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多