我知道它有重复。但仍有问题,甚至在尝试可能性时也没有用。因此发布相同内容以达成解决方案。希望得到你们的帮助。
初始内容嵌入在UINavigationController中。对于初始(着陆视图),必须隐藏导航栏。从着陆视图调用时的其他视图 - 必须显示导航栏。
我正在处理皮革和皮革;通过覆盖视图的方法在着陆视图中显示导航栏,如下所示:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Hiding the navigationbar hidden for the first page
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
//甚至尝过动画:NO&动画:动画
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
// Showing the navigationbar hidden for the first page
[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
当应用程序最初加载时,导航栏处于隐藏状态(正如预期和工作正常)。当从子视图控制器返回到着陆视图时,导航栏会在几秒钟后隐藏 - 着陆视图会加载到ui屏幕上。
我还尝试在着陆视图中使用navigationcontroller委托方法:navigationController: willShowViewController: animated:
。但无法达到我需要的解决方案。
因此我在我的一个childviewcontroller中提供了navigationcontroller委托,并检查弹出时的childcontroller是否不在使用if条件的navigationcontroller的viewcontrollers中。如果是,那么我提供了导航栏的隐藏选项。但也没有解决方案。
在冲浪期间,有一个解决方案来处理viewanimation。我试过了,那也失败了。
再次浏览,提供的解决方案是处理类似的问题与viewwillappear& viewwilldisappear。我眨了眨眼,因为我正在做的方式类似于提议的方式。即便这样也无法达成解决方案。
仅供参考。我正在使用Xcode 6.3,部署目标是6.0以上。我正在使用故事板来管理视图。
请帮我解决问题... App loads is hiding the nav bar in landing page. But when landing page is loaded back from a child view then the nav bar gets hidden only after the landing page loaded on to the ui. I do need to get hidden of the nav bar as like when app loads, when the child view pops and the landing view gets loaded on the top of the controller.
答案 0 :(得分:1)
使用此方法:
[navigationController setNavigationBarHidden:YES];
所以,如果你在某个视图控制器中:
[self.navigationController setNavigationBarHidden:YES];
更多说明:
UINavigationController有一个属性navigationBarHidden,它允许你隐藏/显示整个导航控制器的导航栏。
让我们看看下一个层次结构:
--UINavigationController
----UIViewController1
----UIViewController2
----UIViewController3
三个UIViewController中的每一个都有导航栏,因为它们位于UINavigationController中。例如,你想将bar隐藏到第二个(实际上它与哪一个无关),然后写入UIViewController2:
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES]; //it hides
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO]; // it shows
}
答案 1 :(得分:0)
覆盖自定义member this.SendName name =
if tcpClient.Connected then
// Send name
member this.ThrottleConnection percent =
if tcpClient.Connected then
// Throttle
member this.SendAsTest text =
if tcpClient.Connected then
// Send as text.
类中的委托方法:
UINavigationController
将它放入-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[self setNavigationBarHidden:NO];
if ([viewController isKindOfClass:[SomeViewController class]])
{
[self setNavigationBarHidden:YES];
}
}
课程的一个好处是,您不会使代码混乱UINavigationController
课程
经过测试和工作。
<强>更新强>
创建一个UIViewController
子类:f.e。 UINavigationController
在MyNavigationController
:
AppDelegate.h
然后在#import "MyNavigationController.h"
@property (nonatomic) MyNavigationController *navigationController;
中初始化它:
AppDelegate.m
然后覆盖自定义-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Probably some more code here
self.navigationController = [[MyNavigationController alloc] initWithRootViewController:yourRootViewController];
self.window.rootViewController = self.navigationController;
self.window.backgroundColor = [UIColor blackColor];
[self.window makeKeyAndVisible];
return YES;
}
类
我对故事板几乎没有经验,所以不确定如何设置自定义UINavigationController
,但这就是我在代码中的操作方式。
Here's另一个SO发布如何创建用于故事板的自定义UINavigationController
。