创建新的视图控制器后如何创建视图控制器文件? [英] How do I create a view controller file after creating a new view controller?

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

问题描述

我正在开发选项卡式应用程序.

I am developing a tabbed application.

当我创建一个新的视图控制器并将其链接到选项卡栏控制器时,与其他两个默认视图控制器不同,该控制器没有viewcontroller.swift文件.

When I create a new view controller and link it to the tab bar controller, unlike the other two default view controllers, this one has no viewcontroller.swift file.

如何创建此文件?

我正在使用Xcode 6并在Swift中开发应用程序.

I am using Xcode 6 and developing the app in Swift.

推荐答案

正确,将视图控制器对象拖到情节提要上以创建新场景时,它也不会自动为您创建新类

Correct, when you drag a view controller object onto your storyboard in order to create a new scene, it doesn't automatically make the new class for you, too.

已在情节提要中添加了新的视图控制器场景,然后您必须:

Having added a new view controller scene to your storyboard, you then have to:

  1. 创建一个UIViewController子类.例如,转到左侧项目导航器面板中目标的文件夹,然后单击 control -单击并选择"New File ...".选择一个可可接触类":

  1. Create a UIViewController subclass. For example, go to your target's folder in the project navigator panel on the left and then control-click and choose "New File...". Choose a "Cocoa Touch Class":

然后为新的视图控制器子类选择一个唯一的名称:

And then select a unique name for the new view controller subclass:

将此新子类指定为您刚刚添加到情节提要中的场景的基类.

Specify this new subclass as the base class for the scene you just added to the storyboard.

现在使用新的视图控制器子类为该新场景连接任何IBOutletIBAction引用.

Now hook up any IBOutlet and IBAction references for this new scene with the new view controller subclass.

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

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