根据某些条件为一个选项卡显示不同的控制器
当用户点击“收藏夹”选项卡时,我需要显示:
- 介绍如何添加收藏夹(如果没有收藏夹)
- 否则显示收藏夹列表
因此,当用户点击选项卡按钮时,我需要检查是否有任何收藏夹然后决定使用哪个控制器,我该怎么做?
谢谢!
When user taps on Favourites tab, I need to show:
- Introduction of how to add favourite, if there is no favourite
- Otherwise show the list of favourites
So when user taps on the tab button, I need to check if there is any favourite then decide which controller to use, how do I do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果简介是静态的,没有重要的用户交互,您可以将简介放入包含收藏夹列表的视图顶部的子视图中。设置其框架大小以覆盖收藏夹列表。 (用户将使用下面的代码将其关闭。)将此称为介绍视图。将introductionView 放在顶部的一种方法是在创建收藏夹视图列表时最后添加该子视图。
在收藏夹列表的视图控制器中,转到 viewWillAppear 并添加以下行:
(如果已经有收藏夹,则假设用户已经完成了介绍。)
添加一些代码以在用户按下关闭按钮时运行
。当点击收藏夹选项卡时,这将始终显示介绍视图,除非已经有一些收藏夹名单。阅读UIView 类参考 和 UIViewController 类参考。查看列出的方法可以更好地了解其作用。
祝你好运。
If the introduction is static, with no significant user interaction, you can place the introduction into a subview that is on top in the view containing the list of favorites. Set its frame size to cover up the favorites list. (It will be dismissed by the user with the code below.) Call this the introductionView. One way to put the introductionView on top is to add that subview last when you create the list-of-favorites view.
In your view controller for your list of favorites, go to viewWillAppear and add these lines:
(If there are already favorites, this assumes the user has been through the introduction.)
Add some code to run when the user presses the dismiss button
This will always show the introductionView when the favorites tab is hit, unless there are some favorites already on the list. Read the UIView class reference and the UIViewController class reference. Look at the methods listed to get a better feel what this is doing.
Good luck.