简体   繁体   English

故事板的 Swift 输入和事件处理

[英]Swift Input and event handling for storyboards

I've been trying to outline the basic functionality of a swift application I was developing.我一直在尝试概述我正在开发的 swift 应用程序的基本功能。 I created a basic gui with the storyboard functionality that xcode provides.我使用 xcode 提供的故事板功能创建了一个基本的 gui。 Here is a picture of what it looks like currently:这是它目前的样子的图片: 在此处输入图片说明

What I want to do next is code up a way to receive and store input from the text fields I outlined in the storyboard.我接下来要做的是编写一种方法来接收和存储来自我在情节提要中概述的文本字段的输入。 Additionally I want to receive information regarding certain settings that are placed from the switches I outlined in the second screen.此外,我想接收有关从我在第二个屏幕中概述的开关放置的某些设置的信息。

I've been looking through the files that xcode provides me but I haven't been able to find the one that contains the functionality for the storyboards.我一直在查看 xcode 提供给我的文件,但我一直无法找到包含故事板功能的文件。 If someone could point me in the right direction for that i would greatly appreciate it.如果有人能指出我正确的方向,我将不胜感激。 Ultimately I just want to be able to manage the input provided by the interface I outlined below.最终,我只想能够管理我在下面概述的界面提供的输入。 Thanks!谢谢!

  1. For each view controller on the storyboard make a subclasses of UIViewController .为故事板上的每个视图控制器创建一个UIViewController的子类。

  2. In the inspector panel on the left of the storyboard set the class of each view controller to their respective subclass of UIViewController .在故事板左侧的检查器面板中,将每个视图控制器的类设置为它们各自的UIViewController子类。

  3. Open up the .swift file for that view controller and storyboard and ctrl + drag from the textField to the class this will cause a small popup where you can create an IBOutlet or IBAction.打开该视图控制器和故事板的 .swift 文件,然后按住 ctrl + 从 textField 拖动到类,这将导致一个小弹出窗口,您可以在其中创建一个 IBOutlet 或 IBAction。

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

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