2017-02-17 35 views
0

如果用戶打開應用程序,然後在最後一個tabbar項目上選項卡,它將他帶到login viewcontroller,下面它工作。用戶註冊或輸入他的憑據,然後他可以看到他的profile view controllerTabBar[4]表示在TabBar跳過ViewController

TabBar [4] -> Nav Controller ->Login -> User Profile 

但是最後一個項目,如果已​​經註冊或登錄的用戶,我怎麼可能能夠直接打開用戶Profile ViewController,換句話說,我怎麼會跳到什麼Login viewcontoller

TabBar [4] -> Nav Controller -> User Profile 

回答

0

您應該跳過初始化Nav Controller以及。
當用戶登錄時,User Profile應該直接是TabBar的成員。 考慮下面的一些代碼:

UITabBarController *tabBar = [[UITabBarController alloc] init]; 

// FirstViewController 
First *firstVC = [[First alloc]init]; 
firstVC.title = @"First"; 
firstVC.tabBarItem.image = [UIImage imageNamed:@"1.png"]; 

//SecondViewController 
Second *secondVC = [[Second alloc] init]; 
secondVC.title = @"Second"; 
secondVC.tabBarItem.image = [UIImage imageNamed:@"2.png"]; 

//ThirdViewController 
Third *thirdVC = [[Third alloc] init]; 
thirdVC.title = @"Third"; 
thirdVC.tabBarItem.image = [UIImage imageNamed:@"3.png"]; 

//The User Profile Screen 
UserProfileVC *userProfile = [[UserProfileVC alloc] init]; 
userProfile.title = @"User Profile"; 
userProfile.tabBarItem.image = [UIImage imageNamed:@"4.png"]; 

tabBar.viewControllers = @[firstVC, secondVC, thirdVC, userProfile]; 
+0

請您提供更多詳細信息?如果我刪除了「導航控制器」並直接將標籤欄連接到「LogViewController」,那麼會發生什麼'TabBar圖像?在故事板中,您應該設置Tabbar圖像。 – hotspring

+0

@hotspring請記住,您正在開啓該應用程序,因此如果用戶正在登錄,甚至不應創建「Nav Controller」。檢查編輯,我已經添加了一個編程方式的小片段。 – ystack

+0

你的意思是在tabbar上沒有連接到loginviewcontroller或userprofileviewcontroller,而是以編程方式執行?我還是不明白。我已經將所有其他視圖控制器設置爲TabBar。唯一一個分配給通過導航控制器連接的登錄/ userprofile。 – hotspring