gpt4 book ai didi

ios - 防止 UIPopover 上的动画被外面的点击取消?

转载 作者:可可西里 更新时间:2023-11-01 04:23:47 26 4
gpt4 key购买 nike

当用户在弹出窗口外点击时,关闭动画。有没有办法将解雇动画设置为否?我在 google 上广泛搜索了 Stack。

UIPopover 状态的文档:

When displayed, taps outside of the popover window cause the popover to be dismissed automatically. To allow the user to interact with the specified views and not dismiss the popover, you can assign one or more views to the passthroughViews property. Taps inside the popover window do not automatically cause the popover to be dismissed. Your view and view controller code must handle actions and events inside the popover explicitly and call the dismissPopoverAnimated: method as needed.

我已经使用 NO 实现了 dismissPopoverAnimated: 方法,这对我调用该方法的所有情况都非常有效。

问题是当用户在弹出窗口外点击以关闭时,dismissPopoverAnimated: 不会被调用。

taps outside of the popover window cause the popover to be dismissed automatically.

并且这种解雇是动画化的。 似乎没有办法控制这种解雇。我正在使用弹出窗口为绘图应用程序呈现颜色选择器。在弹出窗口完成动画之前,不会注册点击绘制。这会造成明显的延迟,因为您无法立即绘制,而必须等待动画完成。

我认为 - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController 可以工作,但 AFAIK 无法在此方法中设置动画属性。只需返回是或否。

是否有其他方法可以将动画设置为“否”?

最佳答案

在呈现您的 UIPopoverController 的 View Controller 中,遵循 UIPopoverControllerDelegate 协议(protocol)并实现以下委托(delegate)方法。我刚刚对此进行了测试,它确实消除了没有动画的弹出窗口。

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
[self.myPopoverController dismissPopoverAnimated:NO];
return YES;
}

只需确保您已将弹出框 Controller 的委托(delegate)设置为实现它的 View Controller 。

关于ios - 防止 UIPopover 上的动画被外面的点击取消?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202897/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com