objective-c – 使用淡出动画关闭旋转时的UIPopover

Apple页面和数字应用程序具有弹出窗口(用于“工具”等),当您旋转设备时,它们会以可爱的淡出效果关闭.我正在尝试重新创建这个,但我的弹出窗口似乎总是立即关闭,因此旋转的动画看起来并不那么平滑.我目前正在使用:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{    
    [toolsPopoverController dismisspopoverAnimated:YES];
}

有没有人知道在Pages / Numbers中实现相同效果的最佳方法

谢谢!

解决方法

基于UIPopoverController的文档(重点添加):

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.

看起来通过在willAnimateRotationToInterfaceOrientation:方法调用[toolsPopoverController dismisspopoverAnimated:YES],您将在旋转过渡期间隐藏弹出窗口时忽略动画.

如果在didRotateFromInterfaceOrientation:方法调用dismisspopoverAnimated:YES方法,则在调用dismiss动画之前,应在新位置使用popover的认行为.

如果此时认动画仍然不是您想要的,我会创建一个自定义动画块并明确管理淡出或重新调整大小以满足您的需求.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...