在 Cocoa 中引用父级
我的问题是关于如何从 TabBarController 的一个视图控制器中访问 TabBarController 。
想象一下 mainClass.m 添加了 tabBarController,它有两个 viewController - viewController1 和 viewController2。
在viewController1.m中有一个游戏。当游戏结束时,viewController1.m想要告诉tabBarController显示viewController2,但是viewController1没有引用tabBarController。如何引用 viewController 的父级?
如何从当前视图的代码中更改 tabBarItems?
My question is about how to access the TabBarController from within one of its viewControllers.
Imagine a mainClass.m that adds tabBarController which has two viewControllers - viewController1 and viewController2.
In viewController1.m there is a game. When the game is over, viewController1.m wants to tell tabBarController to display viewController2, but viewController1 has no reference to tabBarController. How do I reference the viewController's parent?
How does one change tabBarItems from within the code for the current view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过视图控制器的 tabBarController 属性。
其中“self”是 viewController1
viewControllers 的 tabController 属性
setViewControllers:animated: UITabBarController 的方法
另外,从技术上讲,tabBarController 不是任何视图控制器的父级。这样说是令人困惑的 Objective-C 中的继承是如何工作的。您的视图控制器的超类或父类是 UIViewController。
Via the tabBarController property of your view controller.
Where "self" is viewController1
tabController property of viewControllers
setViewControllers:animated: method of UITabBarController
Also, technically, the tabBarController is not any view controller's parent. To say it that way is confusing how inheritance works in Objective-C. Your view controller's super class, or parent, is UIViewController.