我已经创建了一个从笔尖加载其内容的自定义视图,就像这样:用笔尖为子视图自定义视图似乎并没有被加载
/* PricingDataView.h */
#import <UIKit/UIKIt.h>
@interface PricingDataView : UIView {
UIView *contentView;
}
@property (nonatomic, retain) IBOutlet UIView *contentView;
@end
/* PricingDataView.m */
#import "PricingDataView.h"
@implementation PricingDataView
@synthesize contentView;
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
[[NSBundle mainBundle] loadNibNamed:@"PricingDataView" owner:self options:nil];
[contentView setFrame:frame];
[self addSubview:contentView];
}
return self;
}
/* ... */
在我设置PricingDataView
作为笔尖文件文件所有者的类型,并连接IB中的contentView
插座。我将Interface Library中的常规UIView
放置到向用户显示的全尺寸视图中,然后将其类名更改为PricingDataView
。它都是构建的,但是在运行时,我的自定义视图应该不会呈现任何内容。
我在PricingDataView.initWithFrame
中放置了断点,但它们没有命中,所以我知道我错过了一些会导致视图初始化的东西。我很好奇的是,在从nibs加载其他视图的过程中,所有的初始化都发生在我身上,而不是这个。为什么?