具有默认启动视图的 UITabBarController
我有一个UITabBarController
,以及我想显示一条启动消息的视图之一,该消息描述了它自己和方向(这是一个用于选择随机运动队的视图)。导航栏上会有一个单独的按钮,按下该按钮时,将使用有关随机运动队的视图填充 UIView
。再次按下该按钮,就会显示不同的团队。因此,假设我转到 UITabBar
上列出的另一个项目,然后返回到此随机视图。我希望该视图是最后显示的运动队,而不是启动方向页面。有人对如何实施这个案例有什么建议吗?
I have a UITabBarController
, and one of the views I would like to display a startup message describing itself with directions (This is a view for selecting random sports teams). There would be a separate button on the navigation bar, which when pressed would populate the UIView
with a view about a random sports team. Press that button again, and a different team is displayed. So, let's say I go to a different item that's listed on the UITabBar
, and later return to this random view. I want the view to be the last sports team displayed, not the startup directions page. Does anyone have any suggestions as to how to implement this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您通过 viewDidDisappear 方法离开该视图后,实现一些算法来随机加载该视图中的数据
编辑:从头开始,使用 UITabBarDelegate 方法。据我了解,每次用户按下它时,您都会尝试以不同的方式加载视图。
当你的标签栏项目被按下时,这个方法被调用,你可以检查标签栏项目是否是你想要的标签栏项目,然后做一些随机数在该方法中生成并可能使用随机数从包含团队对象的 NSArray 加载视图。欲了解更多信息,请阅读:
http://developer.apple.com /library/ios/#documentation/uikit/reference/UITabBarDelegate_Protocol/Reference/Reference.html
和 在 Objective-C 中生成随机数
Implement some algorithm to random the data to load in that view after u leave that view through viewDidDisappear method
EDIT: Scratch that, use UITabBarDelegate method. From what i understand you are trying to load a view differently every time the user pressed it.
This method is called when your tab bar item is pressed, you could check whether the tab bar item is the tab bar item you wanted then do some random number generation in that method and load the view probably from an NSArray containing the team objects using the random number. For more information, read up:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarDelegate_Protocol/Reference/Reference.html
and Generating random numbers in Objective-C