【发布时间】:2010-04-12 21:10:04
【问题描述】:
.嗨,
我有一个 nib 文件,其中包含将在我的大多数视图中使用的标题,因此我可以在需要时只更改它的布局一次。我想知道是否可以使用界面生成器添加标题 nib 视图,或者我是否需要以编程方式执行此操作以及应该如何完成。
我考虑过将subview的子类设置为自动加载nib文件的UIView子类。
- (id)initWithFrame:(CGRect)frame {
UIView *cell;
NSArray *nib = [[NSBundle mainBundle] loadNibNamed: @"MainHeaderView"
owner: self
options: nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass: [UIView class]])
cell = (UIView *) oneObject;
if ((self = [super initWithFrame: [cell frame]])) {
// Initialization code
}
return self;
}
但这似乎也不起作用。
【问题讨论】:
标签: iphone uiview interface-builder