Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.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-Objective-C:在按下视图控制器时,选项卡栏未显示(其正在隐藏)_Ios_Objective C_Navigationbar_Tabbar - Fatal编程技术网

iOS-Objective-C:在按下视图控制器时,选项卡栏未显示(其正在隐藏)

iOS-Objective-C:在按下视图控制器时,选项卡栏未显示(其正在隐藏),ios,objective-c,navigationbar,tabbar,Ios,Objective C,Navigationbar,Tabbar,我的故事板如下: 我的appdelegate: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UITabBarController *tabBa

我的故事板如下:

我的appdelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"rootTabBarVC"];
    self.window.rootViewController = tabBarController;
    return YES;
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
VC1 *contr = [storyboard instantiateViewControllerWithIdentifier:@"VC1"];
[self.navCon pushViewController:contr animated:YES];
我有侧菜单,从中我按下VC1如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"rootTabBarVC"];
    self.window.rootViewController = tabBarController;
    return YES;
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
VC1 *contr = [storyboard instantiateViewControllerWithIdentifier:@"VC1"];
[self.navCon pushViewController:contr animated:YES];

我的问题是:VC1正在推,但tabbar被隐藏。因此,任何人都可以帮助我在按下VC时显示tabbar?

可能,当按下时,视图控制器的
隐藏底部工具栏设置为
true
。您也可以像屏幕截图一样在情节提要中检查它。

可能,当按下时,视图控制器的
隐藏底部条形图设置为
true
。您也可以像屏幕截图一样在情节提要中检查该选项。

在您的AppDelegate.h文件集中尝试此选项:

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarCon;
然后在您的AppDelegate.m文件中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *viewController =  [storyboard instantiateViewControllerWithIdentifier:@"InitialNavCon"];
    self.window.rootViewController = viewController; 
}
最后,当您从侧边菜单导航时,您可以将选项卡栏控制器委托UITabBarControllerDelegate置于界面中,然后将appdelegate声明为:

@property (strong, nonatomic) AppDelegate *appDelegate; 
// for NAVIGATION use this :
  self.appDelegate.tabBarCon = [self.storyboard instantiateViewControllerWithIdentifier:@"MainTabBarController"]; // Set your TABBAR CONTROLLER TO "MainTabBarController"
  [[UITabBar appearance] setItemWidth:self.appDelegate.window.frame.size.width/4.0];
  self.appDelegate.tabBarCon.delegate=self;
  [self.navigationController pushViewController:self.appDelegate.tabBarCon animated:YES]; // then navigate
使用以下要素设置初始导航控制器:


您到选项卡栏的连接应该是这样的,每个选项卡都有一个导航控制器:

在您的AppDelegate.h文件集中,尝试一下这个:

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarCon;
然后在您的AppDelegate.m文件中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *viewController =  [storyboard instantiateViewControllerWithIdentifier:@"InitialNavCon"];
    self.window.rootViewController = viewController; 
}
最后,当您从侧边菜单导航时,您可以将选项卡栏控制器委托UITabBarControllerDelegate置于界面中,然后将appdelegate声明为:

@property (strong, nonatomic) AppDelegate *appDelegate; 
// for NAVIGATION use this :
  self.appDelegate.tabBarCon = [self.storyboard instantiateViewControllerWithIdentifier:@"MainTabBarController"]; // Set your TABBAR CONTROLLER TO "MainTabBarController"
  [[UITabBar appearance] setItemWidth:self.appDelegate.window.frame.size.width/4.0];
  self.appDelegate.tabBarCon.delegate=self;
  [self.navigationController pushViewController:self.appDelegate.tabBarCon animated:YES]; // then navigate
使用以下要素设置初始导航控制器:


您与选项卡栏的连接应该是这样的,每个选项卡VC都有一个导航控制器:

尝试将选项卡栏作为根的初始导航控制器设置为窗口的rootviewControllerPush Tabbarcontroller,所选索引为VC1您正在将导航控制器的根视图控制器设置为Tabbarcontroller。。。然后推到导航控制器堆栈上的任何视图都将“推出”Tabbar控制器。当然,这不是您想要的,是吗?尝试将tabBar作为根的初始导航控制器设置为窗口的rootviewControllerPush Tabbarcontroller,所选索引为VC1您正在将导航控制器的根视图控制器设置为Tabbarcontroller。。。然后推到导航控制器堆栈上的任何视图都将“推出”Tabbar控制器。当然,这不是您想要的,是吗?您必须在当前选项卡栏的导航控制器上按下视图控制器。这意味着,每个选项卡栏视图控制器必须嵌入到导航控制器中。但我想这也不是一个好办法。总而言之:如果你在选项卡栏的导航控制器上按下视图控制器,你将无法保持选项卡栏的可见。我已经为VC嵌入了导航,但这个对我也不起作用。你还在像
[self.navCon pushViewController:contr animated:YES]那样按下吗?更新的代码是什么?但实际上,您必须按导航控制器上的某个选项卡栏项。类似于:[self.tabbarcontorller.viewcontrollers.first.navigationController push]的命令。您必须在当前选项卡栏的导航控制器上按下视图控制器。这意味着,每个选项卡栏视图控制器必须嵌入到导航控制器中。但我想这也不是一个好办法。总而言之:如果你在选项卡栏的导航控制器上按下视图控制器,你将无法保持选项卡栏的可见。我已经为VC嵌入了导航,但这个对我也不起作用。你还在像
[self.navCon pushViewController:contr animated:YES]那样按下吗?更新的代码是什么?但实际上,您必须按导航控制器上的某个选项卡栏项。类似于:[self.tabbarcontorller.viewcontrollers.first.navigationController push]让我们来。