Xcode 4.6 无法将文本字段的插座添加为“连接";在 popover 中是灰色的 [英] Xcode 4.6 Can't add outlet for text field as "connection" in popover is greyed out

查看:16
本文介绍了Xcode 4.6 无法将文本字段的插座添加为“连接";在 popover 中是灰色的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助在 XCode 4.6.3 中为文本字段添加出口.(作为背景,我是一个新手,关注 Apple 的hello world"tute 并且我知道 此处.)

I need help adding an outlet for a text field in XCode 4.6.3. (By way of background, I'm a newbie following Apple's "hello world" tute and am up to here.)

我控制并拖动方法声明内的文本字段,然后释放.在显示的弹出窗口中,连接"默认为操作"并显示为灰色.我无法将其更改为Outlet".

I control-drag the text field inside the method declaration then release. In the pop-up that is displayed, "Connection" defaults to "Action" and is greyed out. I can't change it to "Outlet".

如何使其可编辑,以便我可以选择Outlet"?

How can I make it editable so I can choose "Outlet"?

抱歉缺少图片,但我在 Stack Overflow 上太初级了.如果您想要视觉效果,请随时访问 Apple tute,搜索文字你可以配置你刚刚建立的动作连接",然后看下面的图片.

Sorry about the lack of images but I'm too junior on Stack Overflow. If you want a visual, feel free to go to the Apple tute, search for the text "you can configure the action connection you just made", then look at the image underneath.

非常感谢您的帮助,因为我很困.

Would appreciate any help as I'm pretty stuck.

D

推荐答案

如果你控制拖拽到视图控制器的实现部分,就会发生这种情况在 .m 文件中:

That happens if you control-drag into the implementation part of the view controller in the .m file:

@implementation HelloWorldViewController
...
@end

Outlets 将视图控制器的一个属性与 xib 文件中的一个对象连接起来,和属性在对象的接口中声明.

Outlets connect a property of the view controller with an object in the xib file, and properties are declared in the interface of an object.

因此,要创建插座连接,请控制拖动到公共接口部分在 .h 文件中:

Therefore, to create an outlet connection, control-drag into the public interface part in the .h file:

@interface HelloWorldViewController : UIViewController
...
@end

这是教程展示的内容.

或者,您可以通过控制拖动到.m 文件中的私有扩展接口:

Alternatively, you can make the property "private" to the implementation by control-dragging into the private extension interface in the .m file:

@interface HelloWorldViewController ()
...    
@end

这适用于较新的 Xcode 版本,有助于保持公共界面的清洁.

This works with newer Xcode versions and helps to keep the public interface clean.

这篇关于Xcode 4.6 无法将文本字段的插座添加为“连接";在 popover 中是灰色的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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