如何在 Xcode 中的任何视图控制器上创建静态视图? [英] How make static view on any viewcontroller in Xcode?

查看:42
本文介绍了如何在 Xcode 中的任何视图控制器上创建静态视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有趣的问题.我有两个屏幕,我需要第三个屏幕元素(按钮、标签)是静态的,从一个屏幕移动到另一个屏幕时不会改变..所以 MAIN DISPLAY 1 会改变,DISPLAY 2 也会改变,但按钮和其他(例如标签)需要是静态的.

I Have interesting question. I have two screens, I need that would be the third screen elements (buttons, label) are static and do not change when you move from one screen to another. . So MAIN DISPLAY 1 will be change, DISPLAY 2 too , but button and others(label for example) need be static.

非常感谢您的帮助,抱歉,我没有解决此问题的任何代码.因为我不知道这是怎么做到的...

Big Thanks for all help, sorry i don't have any code with this problem. Because i don't know how this make...

推荐答案

好的,所以如果你的 UI 不会改变它的内容,你必须考虑以下几点:

Ok, so if you have a UI that won't change it's content you have to consider the following:

如果用户可以从一个屏幕导航到另一个屏幕,那么您将不得不创建多个视图控制器(可以通过其他方式完成,但这是最简单和最好的方法),它们将拥有自己的 UI,即可以像这样在故事板中轻松创建:

If the user can navigate from one screen to another, then you will have to create multiple view controllers(it can be done in other ways but this is the easiest and best way to doit) that will have their own UI, that can be easily created in storyboards like this:

创建一个使用故事板的新项目(您可以使用支持您需求的 Xcode 模板)

Create a new project that use storyboars (you can use the Xcode templates that support your needs)

在您生成的故事板中,拖放一个新的 UINavigationController,然后在 Attributes inspector 中检查 Is initial view controller

In your generated storyboard, drag and drop a new UINavigationController, and in the Attributes inspector check the Is initial view controller

将另一个 UIViewController 拖入您的故事板,选择您的导航控制器,按住鼠标右键并拖动到新添加的视图控制器,将出现一个弹出窗口,并从该弹出窗口中选择 root view controller.现在新添加的视图控制器将是应用程序将显示的第一个视图.在此视图控制器上添加您的 UI 元素(按钮、标签等).如果您希望在用户点击按钮时显示另一个屏幕,请拖动另一个视图控制器并选择要显示下一个屏幕的按钮,按住右键单击拖动到新添加的视图控制器,从弹出窗口中选择 <代码>推送.现在,当用户点击按钮时,将显示下一个视图控制器,作为奖励,因为您使用的是 iOS,系统将创建一个后退按钮,以便您可以返回到您的第一个视图控制器.

Drag another UIViewController into your storyboard, select your navigation controller, hold right click and drag to the newly added view controller, a popup will appear and from that popup select root view controller. Now the newly added view controller will be the first view that the app will display. On this view controller add your UI elements (buttons, labels, etc). If you want another screen to be shown when a user taps on a button, drag another view controller and select the button from which you want to display the next screen, hold right click drag to the newly added view controller, from the popup select push. Now when the user tap on the button the next view controller will be shown and as a bonus because you use iOS, the system will create a back button so that you can go back to your first view controller.

好的,这是您可以开始和扩展的基本教程,但为此您必须阅读更多内容,在 google/SO 上过夜以寻找解决方案,您将牢记苹果文档和其他成为优秀的 iOS 开发者所必需的.

Ok, this is the a basic tutorial from which you can start and expand, but for that you will have to read more, spend nights on google/SO to find solutions, you will learn apple docs by heart and other things that are required so that you can be a great iOS developer.

我的 iOS 力量与您同在,史蒂夫·乔布斯注视着您的脚步.

My the iOS force be with you and Steve Jobs watch your steps.

这篇关于如何在 Xcode 中的任何视图控制器上创建静态视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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