我的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;
}
我有侧面菜单,我按照以下方式推送VC1:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
VC1 *contr = [storyboard instantiateViewControllerWithIdentifier:@"VC1"];
[self.navCon pushViewController:contr animated:YES];
我的问题是:VC1正在推动但是tabbar被隐藏了。那么,任何人都可以帮我在推VC上显示tabbar吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
在您的 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