Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa touch 引用Cocoa中的父项_Cocoa Touch_Controller_Uitabbarcontroller_Parent Child - Fatal编程技术网

Cocoa touch 引用Cocoa中的父项

Cocoa touch 引用Cocoa中的父项,cocoa-touch,controller,uitabbarcontroller,parent-child,Cocoa Touch,Controller,Uitabbarcontroller,Parent Child,我的问题是如何从一个ViewController中访问TabBarController 假设有一个mainClass.m添加了tabBarController,它有两个ViewController—viewController1和viewController2 在viewController1.m中有一个游戏。游戏结束后,viewController1.m希望告诉tabBarController显示viewController2,但viewController1没有对tabBarControll

我的问题是如何从一个ViewController中访问TabBarController

假设有一个mainClass.m添加了tabBarController,它有两个ViewController—viewController1和viewController2

在viewController1.m中有一个游戏。游戏结束后,viewController1.m希望告诉tabBarController显示viewController2,但viewController1没有对tabBarController的引用。如何引用viewController的父级


如何从当前视图的代码中更改tabBarItems?

通过视图控制器的tabBarController属性

[ self.tabBarController setViewControllers: viewController2 animated: YES ];
其中“self”是viewController1


此外,从技术上讲,tabBarController不是任何视图控制器的父级。这样说会混淆继承在Objective-C中的工作方式。视图控制器的超类或父类是UIViewController。

通过视图控制器的tabBarController属性

[ self.tabBarController setViewControllers: viewController2 animated: YES ];
其中“self”是viewController1


此外,从技术上讲,tabBarController不是任何视图控制器的父级。这样说会混淆继承在Objective-C中的工作方式。视图控制器的超类或父类是UIViewController。

谢谢。这是内置在viewController中的非常棒的功能。如果它对您有效,请不要忘记选择我作为答案:你明白了。我不知道亲子关系是怎么回事,谢谢。这是内置在viewController中的非常棒的功能。如果它对您有效,请不要忘记选择我作为答案:你明白了。我不确定亲子关系是怎么回事。
[ self.tabBarController setViewControllers: viewController2 animated: YES ];