简体   繁体   English

如何以顺序模式管理视图控制器-Swift

[英]how to manage view controllers in a sequential pattern - swift

I'm trying to implement sth like images below. 我正在尝试实现下面的图片。 there are some views that should be displayed in a sequential order and a bar above them shows the flow of tasks. 有些视图应按顺序显示,并且它们上方的条形图显示了任务的流程。

在此处输入图片说明

as it is shown, first profile view should be displayed. 如图所示,应该显示第一个配置文件视图。 when the user clicks on Go to Next View Button second view (price view) should be displayed. 当用户单击“ Go to Next View Button应显示第二个视图(价格视图)。 the top bar shows the current view where we are in it. 顶部的栏显示了当前视图所在的位置。 I've tried PagingMenuController already to create a menu with views and then disable scrolling. 我已经尝试过PagingMenuController创建带有视图的菜单,然后禁用滚动。 but PagingMenuController loads all views at the same time and also i don't know how to go to next menu item within child views. 但是PagingMenuController加载所有视图,我也不知道如何转到子视图中的下一个菜单项。 now I'm thinking of a container view might be helpful but i didn't use container view so far and i don't know it's good for my purpose or not. 现在我在想容器视图可能会有所帮助,但到目前为止我还没有使用容器视图,我也不知道它对我的目的有没有好处。 also i want that top bar without swiping between views (only on buttons) and one enable view at the same time. 我也希望该顶部栏不要在视图之间滑动(仅在按钮上)并且同时启用一个视图。 any helps would be apprectiated. 任何帮助都会得到认可。

Your question is both broad and vague. 您的问题既广泛又模糊。 My answer is also going to be fairly high level. 我的回答也将是相当高的水平。 I suggest you follow my outline, and if you get stuck on a particular step, post your code, tell us about the problem you're having, and we can help you fix it. 我建议您遵循我的概述,如果您陷于某个特定步骤,请发布代码,告诉我们您所遇到的问题,我们会帮助您解决。

This is pretty simple. 这很简单。 Create custom view controller. 创建自定义视图控制器。 Give it a container view at the bottom that would contain the current child view controller. 在底部为其提供一个包含当前子视图控制器的容器视图。 Use view controller transition methods to switch between child view controllers. 使用视图控制器转换方法在子视图控制器之间切换。 You'll want to add layout anchors to each new child view controllers to pin all of it's view's edges to the edges of the container view. 您需要为每个新的子视图控制器添加布局锚点,以将其所有视图边缘固定到容器视图的边缘。

Create a custom control on top to show the dot and highlight the title of the current view controller. 在顶部创建一个自定义控件以显示该点并突出​​显示当前视图控制器的标题。

If you want the next/previous buttons to be on the child view controllers, put them there, and add a delegate property to all the child view controllers that points to the parent view controller, with next and previous methods. 如果希望将下一个/上一个按钮放在子视图控制器上,则将它们放在那里,然后使用next和previous方法将一个委托属性添加到所有指向父视图控制器的子视图控制器。

BTW, in languages, like English, where text is laid out from left to right, I would think your first page would be on the left and the last page would be on the right. 顺便说一句,在英语之类的语言中,文字是从左到右排列的,我想您的第一页应该在左侧,最后一页应该在右侧。 (I think it makes more sense for profile to be on the left and pay on the right.) (我认为将个人资料放在左侧并在右侧进行付款更有意义。)

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

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