如何从应用程序委托中解除 UIActionSheet?
我试图从应用程序委托中关闭 UIActionSheet,以便当您从后台返回时它不会再次显示。我尝试从子类视图控制器中的 viewDidUnload
或 viewDidDisappear
方法中关闭操作表,但当应用程序后台时似乎不会调用该操作表。
因此,我尝试使用应用程序委托来关闭应用程序背景时可能显示的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@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.
尝试在
appDelegate
的applicationDidBecomeActive
方法中关闭。try to dismiss in
applicationDidBecomeActive
method ofappDelegate
.