Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.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
Ios UIABBARCONTROLLER之前的UIViewController_Ios_Objective C_Uitabbarcontroller - Fatal编程技术网

Ios UIABBARCONTROLLER之前的UIViewController

Ios UIABBARCONTROLLER之前的UIViewController,ios,objective-c,uitabbarcontroller,Ios,Objective C,Uitabbarcontroller,我想要一个带有UIView按钮的UIViewController。用户按下按钮后,UITabBarController应显示不同的选项卡 UIViewController *view1 = [[FirstViewController alloc] UIViewController *view2 = [[SecondViewController alloc] self.tabBarController = [[UITabBarController alloc] init]; self.tabB

我想要一个带有UIView按钮的UIViewController。用户按下按钮后,UITabBarController应显示不同的选项卡

UIViewController *view1 = [[FirstViewController alloc] 
UIViewController *view2 = [[SecondViewController alloc] 
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[view1, view2];
如何在UITabBarController之前显示视图


谢谢

您可以通过
appDeleguate
实现这一权利,您可以使用
setRootViewController
将屏幕设置为显示

示例:

ButtonViewController *btnVC = [[ButtonViewController alloc]init];
[self.window setRootViewController:btnVC];
ButtonViewController *btnVC = [[ButtonViewController alloc]init];
[self.window setRootViewController:btnVC];
UINavigationController *navController=[[UINavigationController alloc]
                                                     initWithRootViewController:btnVC];
[self.window setRootViewController:navController];
导航控制器示例:

ButtonViewController *btnVC = [[ButtonViewController alloc]init];
[self.window setRootViewController:btnVC];
ButtonViewController *btnVC = [[ButtonViewController alloc]init];
[self.window setRootViewController:btnVC];
UINavigationController *navController=[[UINavigationController alloc]
                                                     initWithRootViewController:btnVC];
[self.window setRootViewController:navController];

像往常一样,将选项卡控制器设置为根视图控制器。然后用按钮呈现一个模态视图控制器。按下按钮后,关闭模式视图控制器。

它无法正常工作,因为我已经有了一个UINavigationController。你还有其他建议吗?谢谢:)好的,我想我们走对了!但是,当我在UITabBarController上时,会显示一个带有选项卡栏的黑屏,其中没有任何项目。有办法解决这个问题吗?Thanks@user1211109876如果你看到一个黑屏,那一定是你的视图没有连接到控制器上。阅读以下答案if或此答案if或您可以通过代码进行设计这与
UITabBarController
有什么关系?您可以使用所需的任何视图层次结构来设置应用程序。显示选项卡控制器与显示任何其他视图控制器没有什么不同。我同意rmaddy的观点,您只需使用该按钮从根Vc导航到UITabBarController即可。