2013-03-01 114 views
0

我在應用程序委託中添加了標籤欄。當我從我的視圖中推入視圖時,te標籤欄被刪除。我也希望在推送的視圖上的標籤欄。刪除推視圖上的標籤欄

- (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

的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]; 
+0

這將有助於解釋你的代碼。 – 2013-03-01 13:34:36

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; 
} 
0

檢查此屬性的值在UIViewController你是推

@property(nonatomic) BOOL hidesBottomBarWhenPushed 
0

使用此代碼

調用此方法,在這裏呈現UITabBar

In .h,

@property(strong,nonatomic)UINavigationController * navigation; @property(nonatomic,strong)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]; 
[email protected]"First"; 
[localControllersArray addObject:navigation]; 


self.secondViewController = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; 
navigation = [[UINavigationController alloc] initWithRootViewController:secondViewController]; 
[email protected]"second"; 
[localControllersArray addObject:navigation]; 


self.ThirdViewController = [[Third ViewController alloc]initWithNibName:@"Third ViewController" bundle:nil]; 
navigation = [[UINavigationController alloc] initWithRootViewController:ThirdViewController]; 
[email protected]"Third"; 
[localControllersArray addObject:navigation]; 

tabbarcontroller.viewControllers = localControllersArray; 
self.tabbarcontroller.delegate = self; 
[self.tabbarcontroller setSelectedIndex:0]; 
[self.window addSubview:tabbarcontroller.view]; 

}