标题下方NavigationBar上的UiSegmentedControl [英] UiSegmentedControl on NavigationBar below Title

查看:113
本文介绍了标题下方NavigationBar上的UiSegmentedControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手,在我正在开发的应用程序工作期间,我有些疑惑出现了.我正在尝试构建一个屏幕,该屏幕将由多个ViewControllers组成,但是在NavigationBar上,我希望在Title上方有一个UiSegmentedControl,类似于Scope Bar来控制子级ViewController之间的导航.我想构建类似于HealthKit仪表板上的东西:

I am new on iOS Development and during my works for an app I am building right now some doubts have appeared to me. I am trying to build a Screen that will be compounded by multiple ViewControllers, but on the NavigationBar I would like to have a UiSegmentedControl above the Title, something like a Scope Bar to control the navigation between the children ViewController. I wanted to build something similar to what we have on HealthKit Dashboard:

.

您建议采用哪种方法?我了解已经对此进行了一些疑问,但是经过长时间的研究我还没有得出结论.

What kind of approach do you suggest to do that? I understand that some questions have already been done about it, but after a long research I have not got to a conclusion.

在研究过程中,我注意到NavigationBar上的UISearchBar(用于构建范围栏)仅对UITableViewControllers可行,对吗?因此,我认为这不是一种方法.

During my research I noticed that a UISearchBar on the NavigationBar ( to build the Scope Bar ) is only possible for UITableViewControllers, Am I right? So I think that can not be an approach.

我的下一个想法是使用UISegmentedControl手动放置在NavigationBar下面,然后使用Containment Api更改为此屏幕的不同ViewController.这里的问题是,我将不得不在所有子ViewController上复制UISegmentedControl.有什么办法不必重复吗?

My next idea was to use a UISegmentedControl placed manually below the NavigationBar and then use the Containment Api to change to the different ViewControllers for this Screen. The problem here, is I will have to duplicate the UISegmentedControl on all children ViewControllers. Is there any way to not have to duplicate that?

我尝试的另一种方法是为自己的NavigationBar做自己的titleView,并在下面添加一个NavigationBar和UISegmentedControl.我不喜欢这个主意,尝试复制NavigationBar也不顺利.

Another approach I tried was doing my own titleView for the NavigationBar with a NavigationBar and a UISegmentedControl below. I don’t like this idea, neither it went well trying to replicate the NavigationBar.

最后,我认为另一种方法是使用UIPageViewController.尽管这种方法对我来说是一个好主意,但我认为我还必须复制UISegmentedControl.

Finally, another approach I thought was using a UIPageViewController. Although this approach sounds a good idea to me, I think I will also have to duplicate the UISegmentedControl.

最后,我认为最好的解决方案是在NavigationBar上使用UISegmentControl,但我没有看到如何实现此功能.

In the end I think the best solution is to have a UISegmentControl on the NavigationBar, but I am not seeing how to implement this.

您认为实现我的理想的最佳方法是什么?我认为这很容易,因为这是我在许多应用程序中看到的一种模式.有什么建议吗?

What do you think is the best approach to accomplish my ideia? I thought that it would be easy because it is a pattern I see in many apps. Any suggestions?

我正在使用iOS 8的Swift在XCode 6.1.1上执行此操作.

I am doing this on XCode 6.1.1 using Swift for iOS 8.

非常感谢您的帮助.

推荐答案

您可以通过将分段添加为标题视图并设置所需的提示来获得此效果.在界面生成器中,它看起来像这样:

You can get this effect by adding the segment as the title view and setting your desired prompt. In interface builder it looks like this:

这篇关于标题下方NavigationBar上的UiSegmentedControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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