旋转后如何让UIPopoverController保持相同的位置? [英] How to make UIPopoverController keep same position after rotating?

查看:126
本文介绍了旋转后如何让UIPopoverController保持相同的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

旋转后我不能在屏幕上保持弹出相同的位置。有没有这样做,因为只设置了一些框架酥料饼的旋转后的工作可怕什么好办法 popover.frame = CGRectMake(someFrame); 旋转酥料饼后看起来不错,如果只它位于屏幕的中心。

I can't keep popover the same position on the screen after rotation. Is there any good way to do that, because just setting some frame to popover works terrible after rotating.popover.frame = CGRectMake(someFrame); After rotation popover looks fine only if it is in the center of the screen.

推荐答案

Apple在这个问题上有一个Q& A.你可以在这里找到详细信息:

Apple has a Q&A on exactly this issue. You can find the details here:

技术Q& A QA1694在方向更改期间处理Popover控制器

基本上,该技术解释了在视图控制器的 didRotateFromInterfaceOrientation 方法,你会再次呈现弹出过如下:

Basically, the technique explains that in your view controller's didRotateFromInterfaceOrientation method, you will present the pop over again as follows:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    [aPopover presentPopoverFromRect:targetRect.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

欲了解更多信息,请阅读上面的文章,以及< A HREF = http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPopoverController_class/Reference/Reference.html 相对= nofollow> UIPopoverController类参考:

For more information, have a read of the article above, and also the UIPopoverController Class Reference:


如果用户在弹出窗口可见的情况下旋转设备,则popover
控制器会隐藏弹出框,然后在结束时再次显示
轮换。弹出控制器试图为你适当地定位popover
,但你可能不得不再次出现它或在某些情况下隐藏它
。例如,当从条形码
按钮项目显示时,弹出控制器会自动调整弹出窗口的位置
(可能是大小)以考虑更改为
条形按钮的位置项目。但是,如果在旋转期间删除了条
按钮项,或者在视图中从
呈现了一个目标矩形的弹出框,则弹出控制器不会尝试
来重新定位弹出框。在这些情况下,您必须手动隐藏
popover或从适当的新位置再次显示它。您可以在
控制器的didRotateFromInterfaceOrientation:方法中执行此操作,该控制器用于显示弹出窗口。

If the user rotates the device while a popover is visible, the popover controller hides the popover and then shows it again at the end of the rotation. The popover controller attempts to position the popover appropriately for you but you may have to present it again or hide it altogether in some cases. For example, when displayed from a bar button item, the popover controller automatically adjusts the position (and potentially the size) of the popover to account for changes to the position of the bar button item. However, if you remove the bar button item during the rotation, or if you presented the popover from a target rectangle in a view, the popover controller does not attempt to reposition the popover. In those cases, you must manually hide the popover or present it again from an appropriate new position. You can do this in the didRotateFromInterfaceOrientation: method of the view controller that you used to present the popover.

这篇关于旋转后如何让UIPopoverController保持相同的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆