1
我在這裏做錯了什麼?用xib向UIViewController添加一個UIView子類
創建:
CustomTab.h
#import <UIKit/UIKit.h>
@interface CustomTab : UIView {
IBOutlet UIView *view;
}
@property (nonatomic, retain) IBOutlet UIView *view;
@end
CustomTab.m
#import "CustomTab.h"
@implementation CustomTab
@synthesize view;
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
// Initialization code
}
return self;
}
- (void)dealloc {
[super dealloc];
}
@end
- XIB文件中設置了文件的所有者被CustomTab的課,迷上了看法
在我的UIViewController類
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(0, 0, 320, 40); // Replacing with your dimensions
CustomTab *myObj = [[CustomTab alloc] initWithFrame:frame];
[self.view addSubview:myObj.view];
[myObj release];
}
子視圖不會出現在屏幕上。我錯過了什麼?
您期望在IB中出現什麼? – kovpas 2010-10-30 04:43:22
你是如何檢測該視圖沒有出現,給視圖不同的顏色和檢查 – Warrior 2010-10-30 04:44:16
你是什麼意思?我期待看到我的自定義UIView在我的UIViewController子類的頂部,當應用程序加載 – barfoon 2010-10-30 04:44:52