私はIBでカスタムUIを作成し、そのクラスを設定しました。カスタムUIのコントロールの初期化
#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を配置し、それをIBOutlet IUTextView * textViewにリンクしました。 私のUIViewController(IBのライブラリ内のクラスタブから)にこのカスタムビューをドラッグすると、ビューは空です。 - (id)initWithCoder:(NSCoder *)aDecoderは呼び出していますが、textViewはnullです。 どうしたのですか?ありがとう