這個專案的初始視圖控制器是一個導航控制器。我想在用戶登錄后稍后在視圖層次結構中的視圖控制器上顯示選項卡欄控制器。
當我在視圖控制器上嵌入一個 Tab Bar Controller 時,我希望它打開,我以編程方式實作的導航欄會被一個新的導航欄專案覆寫,當按下時,引導用戶回傳登錄頁面。
這是導航欄的代碼。
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//Changes The Title Color
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]];
//Sets The Navigation Controller Font
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
[UIFont fontWithName:@"ArialMT" size:12.0], NSFontAttributeName,nil]];
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x0080ff)];
self.navigationController.navigationBar.translucent = YES;
self.navigationItem.leftBarButtonItem = btnRefresh;
//
self.navigationItem.rightBarButtonItem = btnCompose;
以下是導航欄在視圖控制器上的實作方式:

當 Tab Bar Controller 嵌入我希望它在的 View Controller 中時,會發生以下情況:

在此視圖控制器上顯示標簽欄控制器以保留現有導航欄的正確方法是什么?Apple 關于 Tab Bar Controllers 的檔案似乎很廣泛,似乎應該以編程方式實作。
uj5u.com熱心網友回復:
根據 Apple 檔案 TabBarController 不應該被推送到 UINavigationController。相反,您可以使用 UITabBar 和 UITabBarDelegate 來獲得相同的效果。您可以參考以下檔案鏈接。
https://developer.apple.com/documentation/uikit/uinavigationcontroller/1621887-pushviewcontroller
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/398787.html
