我想知道如何連接我的自定義類和我的.xib。在Interface Builder中,我已將文件所有者的類更改爲我的自定義類。然後我創建了一個IBOutlet並將其連接到.xib的視圖。然後我的自定義類的實例添加到我的UIViewController。我的自定義類是UIView的子類,所以我將它的背景設置爲黑色,並且可以看到它出現在我的UIViewController的頂部。我看不到的是我的.xib?這是我爲我的自定義類代碼...(FreeThrow是我的自定義類... FetView是我的.xib)如何使.xib顯示在自定義類中
@interface FreeThrow : UIView {
IBOutlet UIView *mySquareView;
}
@property(nonatomic, retain)IBOutlet UIView *mySquareView;
-(void)createMe;
@end
@implementation FreeThrow
@synthesize mySquareView;
-(void)createMe {
[self addSubview:mySquareView];
[self setBackgroundColor:[UIColor blackColor]]; // I did this to know my UIViewController is showing this class... which it is
}
@end
這裏是我的東西,我從我的UIViewController調用代碼...
freeThrowView = [[FreeThrow alloc] init];
[freeThrowView createMe];
freeThrowView.frame = CGRectMake(8, 42, 335, 230);
[self addSubview:freeThrowView];
我需要添加哪些代碼?我需要做什麼?問題是什麼?爲什麼我的.xib沒有顯示出來。