2012-10-05 167 views
0

目前我的iPhone應用程序我的工作,我有四個屏幕一樣登錄,A,B和C等。 用戶進入登錄界面的用戶名和密碼字段,然後按登錄按鈕iPhone中的標籤欄標題問題?

-(void)LoginButtonMethod 
{ 

    A *a = [[A alloc]init]; 
    B *b = [[B alloc]init]; 
    C *c = [[C alloc]init]; 

    UINavigationController *navi1 = [[UINavigationController alloc] initWithRootViewController:a]; 
    UINavigationController *navi2 = [[UINavigationController alloc] initWithRootViewController:b]; 
    UINavigationController *navi3 = [[UINavigationController alloc] initWithRootViewController:c]; 

    UITabBarController *TabBar = [[UITabBarController alloc] init]; 
    TabBar.delegate = self; 
    TabBar.viewControllers = [NSArray arrayWithObjects:navi1, navi2, navi3, nil]; 
    [email protected]"A"; 
    [email protected]"B"; 
    [email protected]"C"; 

    [self.navigationController pushViewController:TabBar animated:YES]; 
} 

然後我爲每個類設置導航欄標題,如A作爲Facebook,b作爲雅虎,c作爲谷歌。

最後我運行應用程序,Tabbar標題顯示在A,B,C 然後,我選擇第三個tabbar項目(C),當時tabar標題更改谷歌。 我無法解決這個問題,請幫助我。

由於提前

+0

IA馬糊塗了,你想第3名(C按你)來爲谷歌或沒有? – Suhaiyl

+0

你有沒有設置self.title = @「你的標題」在視圖中爲每個控制器加載可能會這樣可以解決你的問題。 或者你可以只添加ViewController,你面臨的問題 – kamleshwar

+0

這應該工作檢查兩個類中的斷點。 – 2012-10-05 11:25:28

回答

0

蘋果在它的開發者文檔狀態下:

"You never want to push a tab bar controller onto the navigation stack of a navigation controller. Doing so creates an unusual situation whereby the tab bar appears only while a specific view controller is at the top of the navigation stack. Tab bars are designed to be persistent, and so this transient approach can be confusing to users." 

嘗試呈現它

[self presentModalViewController:tabBar animated:YES]; 
0

可以推的TabBar到控制器通過

要麼

[self.navigationController pushViewController:tabBar animated:YES]; 

[self presentModalViewController:tabBar animated:YES]; 

希望這將解決您的問題

0
這個

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

每個方法

視圖控制器把下面的代碼..

self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Comment" image:[UIImage imageNamed:@"Icon-AddComment.png"] tag:0]; 

self.navigationItem.title = @"Comment"; 

它的工作原理