简体   繁体   English

iOS-如何在导航栏下显示栏?

[英]iOS - How to show a bar under navigation bar?

My app have a navigation bar on the top, and a tab bar on botton, over a mapview. 我的应用在地图视图的顶部有一个导航栏,在botton上有一个标签栏。 I need a way to filter some pins of the mapview. 我需要一种方法来过滤mapview的一些图钉。 So, i`m trying to add a bar or something like that, under the navigation bar. 因此,我正在尝试在导航栏下添加一个栏或类似的名称。

http://localhostr.com/file/gjjMqN4/Captura%20de%20Tela%202012-02-02%20s%2011.18.46.png http://localhostr.com/file/gjjMqN4/Captura%20de%20Tela%202012-02-02%20s%2011.18.46.png

This bar will have 2 text views and a button to perform the filtering job. 该栏将具有2个文本视图和一个用于执行过滤作业的按钮。 I need this bar to be retractile by pressing a button on my navigation bar. 我需要通过按下导航栏上的按钮来使该栏伸缩。

If I run the project that way i get this: 如果我以这种方式运行项目,则会得到以下结果:

http://localhostr.com/file/TfqlFnW/Captura%20de%20Tela%202012-02-02%20s%2011.22.07.png http://localhostr.com/file/TfqlFnW/Captura%20de%20Tela%202012-02-02%20s%2011.22.07.png

The bar is floating in the wrong place. 栏浮动在错误的位置。 =s =秒

I`m making it right? 我说对了吗? Or can I make it in another 'best' way? 还是我可以用另一种“最佳”方式做到这一点?

without a bit of code is difficult to say where you're wrong. 没有一点代码就很难说错了。 In the meantime, I suggest another solution: add a barbuttonitem to the navigationbar that open a modal view where you can put the two thextfield and the button; 同时,我建议另一种解决方案:在导航栏中添加一个barbuttonitem,以打开模式视图,您可以在其中放置两个thextfield和按钮; so you have more space for the map e graphically is more "attractive". 因此您有更多空间来显示地图,从而使图表更具“吸引力”。

You have to have an IBOutlet to the toolbar in your controller, and once the view is loaded, eg viewDidLoad , adjust its coordination, ie x and y to hide it. 您必须在控制器的工具栏上有一个IBOutlet,并且一旦加载视图(例如viewDidLoad ,请调整其坐标,即x和y将其隐藏。 Then, you can add a UIBarButtonItem that when triggered, it calls a toggle method to show or hide the toolbar, eg 然后,您可以添加一个UIBarButtonItem ,当触发该UIBarButtonItem时,它将调用toggle方法来显示或隐藏工具栏,例如

 - (IBAction)toggleToolbar { if (toolbar.isInView) [self hideToolbar]; else [self showToolbar]; } - (void) hideToolbar { // implementation to hide the toolbar } - (void) showToolbar { // implementation to show the toolbar } 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM