如何访问在超类中声明的IBOutlets? [英] How to access IBOutlets declared in superclass?

查看:78
本文介绍了如何访问在超类中声明的IBOutlets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我目前正在重构一些共享几个 IBOutlet s和 IBAction 方法的几个视图控制器。我将出口声明和 IBAction 方法移动到一个超类中,从中剪除这些子类。

Hey all; I'm currently refactoring a couple of view controllers that share a few IBOutlets and IBAction methods. I moved the outlet declarations and the IBAction method into a superclass, cutting these out of the subclasses.

当我打开Interface Builder,我发现我看不到在超类中声明的插座或动作。连接仍然存在,因为我在重构之前连接它们,但是它们变灰了。 (重要的是要注意,连接也是工作,因为我的动作触发按钮按下,我的插座被正确修改。)

Now, when I open up Interface Builder, I find that I can't see the outlets or actions declared in the superclass. The connections still exist, as I'd wired them up before the refactoring, but they're grayed out. (It's important to note that the connections also WORK, as my action fires on a button press, and my outlets are modified properly.)

问题是,我怎么能获取界面构建器从超类中识别出口?这是可能的,如果没有,你们都推荐什么?

The question is, how can I get interface builder to recognize outlets from a superclass? Is this possible, and, if not, what do you all recommend?

(只是为了好玩,这里是我的超类头文件)

(Just for fun, here's my superclass header file:)

@interface TFMainViewController : UIViewController {
    UIImageView *logoImage, *thinkfunImage;
    UIButton *buyFullButton;        
}

@property (nonatomic, retain) IBOutlet UIImageView *logoImage, *thinkfunImage;
@property (nonatomic, retain) IBOutlet UIButton *buyFullButton;

-(IBAction) buyFullVersion;

@end

编辑:如果有人想知道, Xcode和IB 3.2.5,与iOS 4.2 SDK。

in case anyone's wondering, I'm using Xcode and IB 3.2.5, with the iOS 4.2 SDK.

推荐答案

我没有意识到,甚至可以连接到大约一个小时前,界面构建器中的超类。因为这是唯一的问题,我可以找到如何做到这一点,我会添加我的答案,即使这个问题是旧的。我的答案是关于Xcode 4,而不是Xcode 3。

I didn't realize it was even possible to connect to superclasses in interface builder until about an hour ago. Since this was the only question I could find regarding how to do this, I'll add my answer, even though this question is old. My answer is with regard to Xcode 4, not Xcode 3.

据我所知,你不能使用助理编辑器连接到超类的插座,但你可以通过点击IB中的文件的所有者来做到。这应该显示在Utilities - >连接检查器中的所有插座。然后,您可以按Ctrl +单击检查器中的插座(点击+号),然后将其拖动到IB中的视图。

As far as I can tell, you can't connect to outlets in a superclass using the assistant editor, but you can do it by clicking on "File's Owner" in IB. That should show all the outlets in Utilities->Connections Inspector. You can then Ctrl+Click on the outlet in the inspector (click on the '+' sign), and drag it over to your view in IB.

这篇关于如何访问在超类中声明的IBOutlets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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