我在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
Run Code Online (Sandbox Code Playgroud)
我在IB中将此视图上的textview文本视图与IBOutlet IUTextView*textView相关联.当我在我的UIViewController上拖动此自定义视图时(从IB的库中的类选项卡),视图为空. - (id)initWithCoder:(NSCoder*)aDecoder正在调用但textView为null.怎么了?谢谢