【发布时间】:2011-01-26 13:57:02
【问题描述】:
我在 IB 中创建了一个自定义 uiview 并为其设置了类。
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface myView : UIControl {
IBOutlet UITextView *textView;
}
@end
#import "myView.h"
@implementation myView
- (void)commonInit
{
[textView setText:@"lajsdfklasdfjl"];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
[self commonInit];
}
return self;
}
-(id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
[self commonInit];
}
return self;
}
@end
我在 IB 中的这个视图上放了一个带有文本的 textview,并将它链接到 IBOutlet IUTextView *textView。 当我将这个自定义视图拖到我的 UIViewController 上时(来自 IB 库中的类选项卡),视图是空的。 - (id)initWithCoder:(NSCoder *)aDecoder 正在调用,但 textView 为空。 怎么了?谢谢
【问题讨论】:
标签: iphone objective-c interface-builder