我在app delegate中添加了标签栏。当我从我的一个视图推动视图时,标签栏被删除。我也希望推出视图上的标签栏。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
AudioViewController * audioViewController = [[AudioViewController alloc] initWithNibName:@"AudioViewController" bundle:nil];
audioViewController.title = @"audio";
audioViewController.tabBarItem.image=[UIImage imageNamed:@"audio 30x30.png"];
ViewController *videoViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
videoViewController.title = @"video";
videoViewController.tabBarItem.image=[UIImage imageNamed:@"video 30x30.png"];
ViewController *aboutViewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
aboutViewController.title = @"about";
aboutViewController.tabBarItem.image=[UIImage imageNamed:@"about1_iPhone.png"];
ViewController *infoViewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
infoViewController.title = @"info";
infoViewController.tabBarItem.image=[UIImage imageNamed:@"info 30x30.png"];
PlaylistViewController *PlaylistViewControllerObj = [[PlaylistViewController alloc]initWithNibName:@"PlaylistViewController" bundle:nil];
PlaylistViewControllerObj.title = @"Playlist";
PlaylistViewControllerObj.tabBarItem.image=[UIImage imageNamed:@"ko.png"];
NSArray *viewControllerArray = [NSArray arrayWithObjects:audioViewController,videoViewController,aboutViewController,infoViewController,PlaylistViewControllerObj,nil];
UITabBarController * myTabbarController = [[UITabBarController alloc] init];
[myTabbarController setViewControllers:viewControllerArray];
navigationControllerObj = [[UINavigationController alloc] initWithRootViewController:myTabbarController];
[navigationControllerObj setNavigationBarHidden:YES animated:NO];
self.window.rootViewController =navigationControllerObj;
}
答案 0 :(得分:0)
UIViewController * viewController1,* viewController2,* viewController3,* viewController4,* viewController5;
viewController1 = [[Homeviewcontroller alloc] initWithNibName:nil bundle:nil];
viewController2 = [[NearbyViewController alloc] initWithNibName:nil bundle:nil];
viewController3 = [[SearchViewController alloc] initWithNibName:nil bundle:nil];
viewController4 = [[FavoritiesViewController alloc] initWithNibName:nil bundle:nil];
viewController5 = [[MoreViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *homeNavi=[[UINavigationController alloc]initWithRootViewController:viewController1];
UINavigationController *SearchNavi=[[UINavigationController alloc]initWithRootViewController:viewController3];
UINavigationController *NearbyNavi=[[UINavigationController alloc]initWithRootViewController:viewController2];
UINavigationController *FavNavi=[[UINavigationController alloc]initWithRootViewController:viewController4];
UINavigationController *MoreNavi=[[UINavigationController alloc]initWithRootViewController:viewController5];
TabbarController = [[UITabBarController alloc] init];
TabbarController.viewControllers = [NSArray arrayWithObjects:homeNavi,SearchNavi,NearbyNavi,FavNavi,MoreNavi, nil];
[self presentModalViewController:TabbarController animated:YES];
答案 1 :(得分:0)
试试此示例代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
AudioViewController * audioViewController = [[AudioViewController alloc] initWithNibName:@"AudioViewController" bundle:nil];
audioViewController.title = @"audio";
audioViewController.tabBarItem.image=[UIImage imageNamed:@"audio 30x30.png"];
UINavigationController *navaudioViewController = [[UINavigationController alloc] initWithRootViewController:audioViewController];
PlaylistViewController *PlaylistViewControllerObj = [[PlaylistViewController alloc]initWithNibName:@"PlaylistViewController" bundle:nil];
PlaylistViewControllerObj.title = @"Playlist";
PlaylistViewControllerObj.tabBarItem.image=[UIImage imageNamed:@"ko.png"];
UINavigationController *navPlaylistView = [[UINavigationController alloc] initWithRootViewController:PlaylistViewControllerObj];
UITabBarController * myTabbarController = [[UITabBarController alloc] init];
myTabbarController.viewControllers = @[navHomeController,navPlaylistView];
self.window.rootViewController = myTabbarController;
[self.window makeKeyAndVisible];
return YES;
}
答案 2 :(得分:0)
检查您正在推送的UIViewController
中此属性的值
@property(nonatomic) BOOL hidesBottomBarWhenPushed
答案 3 :(得分:0)
使用此代码
调用此方法,在何处呈现UITabBar
在.h,
@property(强,非原子)UINavigationController *导航; @property(非原子,强)UITabBarController * tabbarcontroller;
在.m,
- (无效)loadtabview {
self.tabbarcontroller = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
self.firstViewController = [[FirstViewController alloc]initWithNibName:@"firstViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:self.firstViewController];
self.viewController.navigationItem.title=@"First";
[localControllersArray addObject:navigation];
self.secondViewController = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:secondViewController];
self.secondViewController.navigationItem.title=@"second";
[localControllersArray addObject:navigation];
self.ThirdViewController = [[Third ViewController alloc]initWithNibName:@"Third ViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:ThirdViewController];
self.secondViewController.navigationItem.title=@"Third";
[localControllersArray addObject:navigation];
tabbarcontroller.viewControllers = localControllersArray;
self.tabbarcontroller.delegate = self;
[self.tabbarcontroller setSelectedIndex:0];
[self.window addSubview:tabbarcontroller.view];
}