我正在研究一个iOS应用程序。 我的问题是,在我的故事板上,我有一个导航栏显示,但是当我运行该应用程序,它隐藏,我不知道为什么......为什么我的UINavigationbar被隐藏?
首先我有一个“StartViewController”并显示MainViewController,我这样做是:
- (void)finishDownloadDataWithError:(NSError *)error{
//si il ya pas eu d'erreur on arrête la video et on éxecute loadMainView.
if (error == nil) {
NSLog(@"download OK");
//simule un téléchargeemnt de 3s
//[NSThread sleepForTimeInterval:2.f];
_loadingIndicator.hidden = YES;
}
//si il ya eu des erreur on affiche la popup d'erreur.
else {
NSLog(@"download fail");
}
//on utilise ce booléen pour être sur de ne créer qu'une seul fois les instances des controllers
static BOOL firstTime = YES;
if (firstTime) {
firstTime = NO;
//chargement de la vue suivante
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
MainViewController * controller = (MainViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MainViewController"];
[self presentViewController:controller animated:YES completion:nil];
}
}
这里是我的MainViewController
- (void)viewWillAppear:(BOOL)animated{
self.navigationBar.title = @"FoodStash";
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
这里是我的故事板:
这里是没有我的导航栏模拟器!!!! 你能帮我吗?
UPDATE 我尝试这一点,但我mainviewController现在不出现。
//chargement de la vue suivante
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UINavigationController *naviCon = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];
[self presentViewController:naviCon animated:YES completion:nil];
检查'self.n avigationController'为零。 – KudoCC 2014-09-24 07:56:21
他是零...初始化它的最好方法是什么?和哪里?在我的startviewcontroller? – Jeffrey 2014-09-24 08:26:25