【发布时间】:2010-10-30 04:40:15
【问题描述】:
我在这里做错了什么?
创建:
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 中出现什么?
-
你是怎么检测到视图没有出现的,给视图赋予不同的颜色并检查
-
什么意思?我希望在应用加载时在我的 UIViewController 子类上看到我的自定义 UIView
-
@Warrior UIViewController 子类是一种颜色,我的 UIView 子类在 XIB 中是另一种颜色,应用启动时我只看到一种颜色(UIViewControllers)
-
您是否尝试过以编程方式代替 IB
标签: iphone uiview uiviewcontroller iphone-sdk-4.1