gpt4 book ai didi

ios - 为什么我的 UINavigationbar 被隐藏了?

转载 作者:行者123 更新时间:2023-11-29 02:39:01 24 4
gpt4 key购买 nike

我正在开发 iOS 应用程序。我的问题是,在我的 Storyboard上,我显示了一个导航栏,但是当我运行该应用程序时,它是隐藏的,我不知道为什么....

首先,我有一个加载数据并显示 MainViewController 的“StartViewController”,我是这样做的:

 - (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];

}

}

这是我的主视图 Controller

  - (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];

这是我的 Storyboard: enter image description here

here the simulator without my navigationbar !!!!

这是没有我的导航栏的模拟器!!!!你能帮帮我吗?

更新我尝试了这个,但我的 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];

最佳答案

我知道你的问题了。

请检查导航 Controller ,因为是初始 View Controller

enter image description here

之后你的 ViewController 设置为 RootViewController 如下图所示

这是你的结果:

enter image description here
enter image description here

并为 HomeView Controller 设置一个标识符“HomeID”

当你导航时:

 -(void)MOve_screen
{
HomeViewController *home = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"HomeID"];
[self.navigationController pushViewController:home animated:YES];

}

如果有任何疑问,你可以随时问我:)

关于ios - 为什么我的 UINavigationbar 被隐藏了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26011465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com