呈现模态视图偶尔会隐藏导航栏 [英] Presenting modal view occasionally hides the navigation bar

查看:167
本文介绍了呈现模态视图偶尔会隐藏导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在遇到过两次。



有时使用下面的代码:

  [self.navigationController presentModalViewController:aViewController animated:YES]; 

显示视图,但导航栏随后隐藏。



我可以写:

  [self.navigationController setNavigationBarHidden:NO]; 

到我心中的内容,无处不在,我可以想到没有效果。

$ b $

>解决方案

不,我也碰到了这个。问题是,当您提供一个模式视图控制器与基于UIViewController的类,它不会将调用导航控制器的导航栏扩展到模态。模态视图覆盖整个屏幕。我最后做的是解决问题是创建一个UINavigationController,并推送基于UIViewController的类,然后做presentModalViewController到导航控制器的实例。



like:

  UIViewController * vc = [[UIViewController alloc] init]; 
UINavigationController * cntrol = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentModalViewController:cntrol animated:YES];
[cntrol release];

这让我在顶部有一个导航栏。



我不知道这是否会帮助你的特定情况下,唯一的其他事情,我建议是用UIAnimation复制模态的行为,停止44px低于手机的顶部。这将保持原始导航栏显示。


I've come across this twice now.

Sometimes using the following line of code:

[self.navigationController presentModalViewController:aViewController animated:YES];

displays the view, but the navigation bar is then hidden.

I can write:

[self.navigationController setNavigationBarHidden:NO];

to my hearts content, everywhere I can think of with no effect.

Has anyone ran into this?

Am I doing something silly?

解决方案

No, I ran into this as well. The problem is that when you present a modal view controller with a UIViewController based class, it does not extend the calling navigation controller's nav bar onto the modal. The modal view covers the entire screen. What I ended up doing to solve the problem was to create a UINavigationController and push the UIViewController based class onto it, and then do presentModalViewController to the navigation controller's instance.

like:

UIViewController *vc = [[UIViewController alloc] init];
UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentModalViewController:cntrol animated:YES];
[cntrol release];

That allowed me to have a nav bar at the top.

I am not sure if that will help in your particular case, the only other thing I would suggest is to replicate the behavior of the modal with a UIAnimation that stops 44px below the top of the phone. That would keep the original navigation bar visible.

这篇关于呈现模态视图偶尔会隐藏导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆