iOS版的Fragments [英] iOS version of Fragments

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

问题描述

任何人都可以告诉我在Xcode(iPhone)中执行以下操作的最佳方法是什么。

Can anyone tell me what the best way to do the following is in Xcode (iPhone).

我有一个主导航屏幕,上面有一些按钮。当用户点击任何按钮时,他们将被带到具有更多选项按钮的子导航屏幕。在这里,他们点击任何一个按钮,然后进入选项列表。单击任何列表选项将向用户显示包含一些信息的屏幕。这些屏幕中的每一个(无论您使用的应用程序的哪个部分)都看起来都一样。只有这些屏幕上的文字和图片会发生变化。

I have a main navigation screen with some buttons on it. When the user clicks any of the buttons they are taken to a sub-navigation screen with more option buttons on it. Here they click whichever button and are taken to a list of options. Clicking on any list option will display a screen with some information to the user. Each one of these screen ( no matter what section of the app you're in) will look the same. Only text and images on these screens will change.

我附上了一张图表,可以更好地解释它。在Xcode中处理这个问题的最佳方法是什么?我已经尝试在Stroyboard中完成所有操作,因为我是Objective C的新手,但只是单个页面的数量正在减慢我的机器爬行速度。所以需要重新思考。

I have enclosed a diagram that might explain it better. What is the best way to handle this in Xcode? I have tried doing it all in Stroyboard as I'm new to Objective C but just the sheer amount of individual pages is slowing my machine down to a crawl. So a rethink is required.

我也在做这个应用程序的Android版本,我正在使用Fragments。有人可以帮忙吗?

I am also doing an Android version of this app and I'm using Fragments for this. Can anyone please help?

编辑:刚到我的开发机器,这就是我到目前为止所做的。我意识到现在这是完全错误的做法。如果你愿意,我已经为每个屏幕创建了一个视图控制器。

Just got to my devel machine and this is what I have been doing so far. I realise now this is the complete wrong way to do it. I have created a view controller for each "screen" if you like.

所以我只是为所有屏幕创建了一个视图控制器。单个页面如图所示,然后根据选择的屏幕动态添加文本?任何人都可以指向我的教程方向或我需要搜索的内容吗?我不知道从哪里开始使用Xcode。

So I just create one view controller for all "screen" of e.g. Individual Page as per diagram and then add the text dynamically depending on what screen is selected? Can anyone point me in the direction of a tutorial or what I need to be searching for? I have no idea where to start with this using Xcode.

推荐答案

如果视图的元素相同(并且只有实际的文本和图像是在故事板中你需要做的就是创建一个视图控制器,它将拥有所有这些ui元素,然后根据你想要在其中显示的内容,你可以根据代码设置它(取决于用户的内容)点击上一个视图控制器。)

If the elements of the view are the same (and only the actual text and images are changing), all you need to do in your storyboard is to create one view controller that will have all these ui elements, from code you can then set it up depending on the content that you want to display in it (depending on what the user clicked in the previous view controller).

编辑:
不确定为什么它被downvoted,但我会更清楚。很明显,一个视图控制器并不是你需要在故事板中做的所有事情。在图表中名为Page的所有元素相关的故事板上,您需要做的就是这些。然后你必须将它链接到一个PageViewController类和所有与可配置UI元素相关的出口以及 prepareForSegue:方法的代码中的辅助导航屏幕视图控制器您必须根据要显示的内容对其进行配置。

Not sure why it was downvoted, but i'll be more clear. Clearly that one view controller is not ALL you need to do in the storyboard. It's all you need to do ON the storyboard related to all the elements called Page in the diagram. Then you would have to link it to a PageViewController class and to all the outlets related to configurable UI elements and in the code of your prepareForSegue: method from the Secondary Nav Screen View Controller you would have to configure it accordingly to what you want to show.

这里你可以找到一个很好的初学者教程,以及许多其他好的教程。您可能缺少的是,您还需要告诉故事板视图控制器是什么类,以及如何将标签和图像视图等内容连接到实际代码,以便您可以适当地配置它们。

Here you can find a good beginner's tutorial, along with many other good tutorials. What you're probably missing is that you also need to tell the storyboard what class the view controller is and how to connect stuff like labels and imageviews to the actual code so that you can configure them appropriately.

IE

这篇关于iOS版的Fragments的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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