自动旋转时 UIPopOverController 问题

发布于 2024-12-06 02:23:18 字数 144 浏览 4 评论 0原文

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

I am presenting a UIPopovercontroller using PresentPopOverFromRect: method. in Portrait Orientation. When i autorotate to Landscape UIPopoverController is not presenting at the proper position. How to position the UIPopoverController while autorotating the device.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

反目相谮 2024-12-13 02:23:18

您需要重写此函数:

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

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

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

You need to override this function:

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

where you can change the dimension and position of the UIPopovercontroller depending of your current orientation. This function is convenient because it is called just before the screen is being redrawn and just before the user interface begins to rotate.

You should check this tutorial for an understanding of how you should handle the layout for different orientations of the IPad.

世态炎凉 2024-12-13 02:23:18

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

您可以尝试一下!

Yes, as tiguero says, in your custom UIViewController, you can override the method:

-(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];
}

You can have a try!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文