我正在研究一個應用程序,我面臨UINavigationcontroller
的問題。推控制器後隱藏導航控制器
首先在應用程序委託我檢查用戶是否登錄,如果是的話,我把他帶到主屏幕,如果不是,我帶他到登錄屏幕。
這是我的代碼:
UINavigationController *diabetesNavigationController = [UINavigationController alloc];
LoginViewController *loginPage = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];
MainViewController *mainPage = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
if ([DataStore instance].userIsLoggedIn)
diabetesNavigationController = [diabetesNavigationController initWithRootViewController:mainPage];
else
diabetesNavigationController = [diabetesNavigationController initWithRootViewController:loginPage];
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
[[UINavigationBar appearance]setBarTintColor:[UIColor orangeColor]];
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance]setTitleTextAttributes:navbarTitleTextAttributes];
[self.window setRootViewController:diabetesNavigationController];
在用戶登錄時出了問題,他再回到loginscreen但沒有navigationcontroller
。
我做出MainViewController東西,這是這樣的:
-(void)viewDidAppear:(BOOL)animated
{
self.navigationItem.title = @"Diabetes";
UIBarButtonItem *settingButton=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"burger.png"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(onBurger:)];
self.navigationItem.rightBarButtonItem = settingButton;
self.navigationItem.leftBarButtonItem.enabled = YES;
}
所以,當我註銷用戶,使用此代碼:
LoginViewController *loginPage = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];
[self.navigationController setViewControllers:[NSArray arrayWithObjects:loginPage, nil] animated:YES];
我得到的登錄屏幕,但沒有Navigationcontroller
。我試圖在所有視圖代表中將Hidden屬性設置爲NO,但它仍然存在此問題。
你在嘗試 - (空)viewWillAppear中:(BOOL)動畫{[超級viewWillAppear中:動畫] ; [self.navigationController setNavigationBarHidden:NO animated:animated]; { – iiFreeman
是的,我做過,仍然是相同的問題 – Abo3atef
是的,我沒有,仍然沒有工作。 – Abo3atef