目标 C:如何禁用除一个之外的所有选项卡栏的用户交互?
正如标题所示,我希望能够锁定除一个之外的所有选项卡栏。只有在用户完成操作后,我才会启用所有其余的选项卡栏。我怎样才能做到这一点?
As what the title suggests, I would like to be able to lock all my tab bars except for one. And only after the user completes an action will I enable all the rest of the tab bars. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还没有尝试过,但根据 docs,您可以从
tabBarController:shouldSelectViewController:
委托返回 NO。[更新]我只是出于好奇而尝试了 - 它似乎工作得很好。从“选项卡栏应用程序”模板创建一个新项目,然后转到 FirstViewController 的
-viewDidLoad
。添加这一行:然后实现委托方法:
不要忘记在 .h 文件中遵守
!希望有帮助。
I haven't tried it, but according to the docs, you can return NO from the
tabBarController:shouldSelectViewController:
delegate.[UPDATE] I just tried that out of curiosity - it seems to work fine. Create a new project from the "Tab bar application" template and then go to the
-viewDidLoad
of your FirstViewController. Add this line:and then implement the delegate method:
Don't forget to conform to
<UITabBarControllerDelegate>
in your .h file!Hope that helps.
您必须实现此方法
您必须执行类似的操作才能禁用所需的选项卡栏项目。
You have to implement this method
You have to do something like this for disabling your required tabbar items.
UITabBarDelegate
中的tabBar:didSelectItem:
方法可能会有所帮助。The method
tabBar:didSelectItem:
inUITabBarDelegate
could help.