在用户更改到另一个选项卡之前强加一个需要满足的条件
我遇到的情况是,我需要确保用户在移动到 UITabBarController 内的另一个选项卡之前已完成某些步骤。因此,如果用户正在执行某些操作并点击另一个选项卡,我想显示一个 UIAlertView
,说明“在转到另一个选项卡之前,您必须完成等等”。
是否可以检查此条件并取消移动到另一个视图控制器?
I have situation where I need to make sure that user has completed certain steps before they move to another tab inside UITabBarController
. So if the user is in middle of something and taps on another tab, I would like to show a UIAlertView
saying "you must complete blah blah blah before you go to another tab."
Is it possible to to check this condition and cancel moving to another view controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然可以。我想您的标签栏控制器位于 AppDelegate 类中。如果是这样,请将 AppDelegate 设置为其委托。然后执行下面的方法
Sure you can. I suppose you have your tabbar controller in the AppDelegate class. If so, set the AppDelegate to be its delegate. Then implement the following method
猜测您可以尝试捕获正在退出的视图,并将选项卡栏控制器上的选定索引更改为您希望保留它们的视图:
您可能会发现这有点不稳定,但根据事件的顺序,快速谷歌发现,如果你可以让你的视图控制器成为 UITabBarControllerDelegate 那么你可以实现:
这将允许你更早地捕获它们。您可能会发现在应用程序委托中实现此操作并让它知道(或检查)是否应该允许更改是最简单的。
At a guess you could try catching the view on it's way out and changing the selected index on the tab bar controller to be the view you wish to keep them on:
You might find that's a bit jerky though depending on the order of events, a quick google has found that if you can make your view controller a UITabBarControllerDelegate then you can implement:
Which would allow you to catch them earlier. You might find it simplest to implement this in your App Delegate and have it know (or check) if it should allow the change away.