简体   繁体   English

当我使用导航 controller 时视图消失时出现黑条

[英]black bar as the view fades when I am using navigation controller

I'm writing my first iPhone app and I am trying to figure out how to have a MasterView and DetailsView like in the example.我正在编写我的第一个 iPhone 应用程序,并试图弄清楚如何像示例中那样拥有 MasterView 和 DetailsView。 However, instead of using a TableView, I want to use a button on the MasterView to go to the SignUpView.但是,我不想使用 TableView,而是想使用 MasterView 上的按钮到 go 到 SignUpView。 I want the MasterView to NOT have a navigation bar but the SignUpView needs to have one.我希望 MasterView 没有导航栏,但 SignUpView 需要有一个。

I have tried putting a NavigationController into the MasterView using the interface builder.我尝试使用界面构建器将 NavigationController 放入 MasterView 中。 This doesn't seem to do anything at all... Ie I make the following call:这似乎根本没有做任何事情......即我打了以下电话:

[self.navigationController pushViewController:signUpViewController animated:YES];

And nothing happens.什么也没有发生。 The SignUpView is never shown. SignUpView 永远不会显示。

So then I declared a NavigationController in the AppDelegate.于是我在 AppDelegate 中声明了一个 NavigationController。 The above call in the same function that it was in before (button handler, button is in MasterView) works now.上面的调用在相同的 function 中(按钮处理程序,按钮在 MasterView 中)现在可以工作。 It takes me to the SignUpViewController.它带我到 SignUpViewController。

however, the issue is, when I press back on the navigation bar in the sign up view, the navigation bar shows up again in the MasterView.但是,问题是,当我在注册视图中按回导航栏时,导航栏再次出现在 MasterView 中。 I tried to set我试图设置

self.navigationController.navigationBarHidden = YES;

in viewDidLoad and viewDidAppear, but that causes a black bar to appear in the transition from SignUpView to MasterView.在 viewDidLoad 和 viewDidAppear 中,但这会导致在从 SignUpView 到 MasterView 的过渡中出现黑条。

I tried to not set it in one of the two, and that causes the animation to go smoothly, but the navigation bar shows up in the MasterView.我试图不将其设置为两者之一,这会导致 animation 顺利转换为 go,但导航栏显示在 MasterView 中。

I feel like this should be pretty simple to do... but I'm at my wits end trying to figure this out.我觉得这应该很简单......但我正在努力解决这个问题。 Some help would be really appreciated!一些帮助将不胜感激!

Thanks.谢谢。

Probably not the answer to your question, but just a small suggestion.可能不是您问题的答案,而只是一个小建议。 In the many apps that I have come across, a sign-up/sign-in view is generally displayed as a modal view (on top of your master view) with a 'cross' in the top-right corner to dismiss it.在我遇到的许多应用程序中,注册/登录视图通常显示为模态视图(在主视图顶部),右上角有一个“十字”以将其关闭。 Probably it results in a better user experience.可能它会带来更好的用户体验。

Also, did you try self.navigationController.navigationBarHidden = YES ;另外,您是否尝试self.navigationController.navigationBarHidden = YES in the MasterView's viewWillAppear ?在 MasterView 的viewWillAppear中?

HTH,高温下,

Akshay阿克谢

I had this problem too, until I discovered setNavigationBarHidden.我也有这个问题,直到我发现了 setNavigationBarHidden。 You will probably want to use these in viewWillAppear/viewWillDisappear or viewDidAppear/viewDidDisappear.您可能希望在 viewWillAppear/viewWillDisappear 或 viewDidAppear/viewDidDisappear 中使用这些。 You don't want to call this in viewDidLoad because that is only called once when the view is initialized, not every time it appears.您不想在 viewDidLoad 中调用它,因为它只在视图初始化时调用一次,而不是每次出现时调用。

To hide:隐藏:

[self.navigationController setNavigationBarHidden:YES animated:YES];

To show:以显示:

[self.navigationController setNavigationBarHidden:NO animated:YES];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用导航控制器时如何初始化视图 - How Do I Initialize a View When Using Navigation Controller 当我在iPhone的导航栏上单击时,如何弹出所需的视图控制器 - How can i pop to a required view controller when i click on back on navigation bar in iPhone 当设置根视图控制器编程导航和标签栏丢失时 - When set root view controller programmatically navigation and tab bar missing 当导航栏可见时为详细视图控制器创建自动布局 - Create autolayout for detailed view controller when navigation bar is visible 导航栏在推送到新视图时会缩小 controller - Navigation bar shrinks when pushed to the new view controller 带有可见导航栏的视图控制器弹出带有隐藏导航栏的视图控制器时带有interactivePopGestureRecognizer的黑色区域 - Black area with interactivePopGestureRecognizer when popping a view controller with visible nav bar to a one with hidden nav bar 如何在不使用导航控制器或导航栏的情况下从Xib返回main.storyboard中的视图控制器? - How to return to view controller in main.storyboard from a xib without using navigation controller or navigation bar? 加载导航控制器时出现黑屏 - Getting black screen when loading navigation controller 我无法使用JSQMessagesViewController获得导航栏 - I am not able to get Navigation Bar using JSQMessagesViewController 选项卡栏控制器位于导航控制器内,或共享导航根视图 - Tab bar controller inside a navigation controller, or sharing a navigation root view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM