【发布时间】:2014-09-24 07:54:01
【问题描述】:
我正在开发一个 ios 应用程序。 我的问题是在我的故事板上我有一个显示的导航栏,但是当我运行应用程序时,它是隐藏的,我不知道为什么....
首先我有一个“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];
}
这是我的故事板:
这是没有我的导航栏的模拟器!!!! 你能帮帮我吗?
更新 我试试这个,但我的 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.navigationController是否为nil。 -
他是零……初始化它的最佳方法是什么?在哪里?在我的 startviewcontroller 中?
标签: ios xcode uinavigationcontroller ios8 xcode-storyboard