【发布时间】:2010-07-30 04:13:19
【问题描述】:
将 subview 添加到 self 和 or 到 content view 有什么区别?
子视图添加到自己
- (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) {
UIImage *img = [UIImage imageNamed:@”lol.jpg”];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self addSubview:imgView];
[imgView release];
return self;
}
子视图添加到 contentView
- (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) {
UIImage *img = [UIImage imageNamed:@”lol.jpg”];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self.contentView addSubview:imgView];
[imgView release];
return self;
}
【问题讨论】:
标签: iphone objective-c cocoa-touch uitableview