如何从应用程序委托中解除 UIActionSheet?

发布于 2024-11-14 22:41:58 字数 271 浏览 3 评论 0原文

我试图从应用程序委托中关闭 UIActionSheet,以便当您从后台返回时它不会再次显示。我尝试从子类视图控制器中的 viewDidUnloadviewDidDisappear 方法中关闭操作表,但当应用程序后台时似乎不会调用该操作表。

因此,我尝试使用应用程序委托来关闭应用程序背景时可能显示的UIActionSheet。但我不知道该打电话给什么。有人有解决办法吗?或者有更好的主意来完成同样的事情?

谢谢。

I'm trying to dismiss a UIActionSheet from the app delegate so that it doesn't show again when you return from background. I've tried to dismiss the action sheet from the viewDidUnload or viewDidDisappear methods in the subclass view controller, but that doesn't seem to get called when the app backgrounds.

Therefore, I'm trying to use the app delegate to dismiss either UIActionSheet that may be showing when the app backgrounds. But I can't figure out what to call. Does anyone have a solution? Or a better idea to accomplish the same thing?

Thanks.

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

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

发布评论

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

评论(2

贪恋 2024-11-21 22:41:58

@Dylan你可以做的是你可以声明你的 uiactionsheet 变量的属性并合成它。

然后,在 applicationDidBecomeActive 方法的 appdelegate 中,您可以通过执行类似 [viewController.actionSheet dismissWithClickedButtonIndex:0animated:NO] 的操作来调用解雇方法来解雇该操作表。假设您的应用程序委托中有引用。

但如果没有,那么您可以找到 uiwindow 顶部显示的所有 UIView,然后检查是否有任何 uiview 是显示操作表的类。之后,一旦您掌握了显示操作表的 viewController,您就可以通过执行与上面相同的操作来关闭操作表。

@Dylan what you can do is you can declare the property for your uiactionsheet variable and also synthesis it.

Then in appdelegate in applicationDidBecomeActive method you can dismiss that actionsheet by calling the dismiss method by doing something like this [viewController.actionSheet dismissWithClickedButtonIndex:0 animated:NO]. Assuming that you have the reference in your appdelegate.

But if not then you can find all the UIViews shown on top of the uiwindow and then check if any of the uiviews is kind of class that is showing actionsheet. After that you can dismiss the actionsheet by doing the same as written above once you have the hold of that viewController that is showing actionsheet.

流殇 2024-11-21 22:41:58

尝试在 appDelegateapplicationDidBecomeActive 方法中关闭。

try to dismiss in applicationDidBecomeActive method of appDelegate.

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