假设我创建了myTableViewCell类:
#import "MyTableViewCell.h"
@implementation MyTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
UIImageView *imgSponsor=[[UIImageView alloc ] initWithFrame:CGRectMake(0,0,self.bounds.size.width,200)];
imgSponsor.image = [UIImage imageNamed:@"imageFirstCell"];
[self.contentView addSubview:imgSponsor];
}
return self;
}
[...]
@end
除了运行相关的tableviewcontroller方法(heightForRowAtIndexPath ..)之外,我可以在此类中设置此单元格的默认高度吗?
答案 0 :(得分:1)
您可以在MyTableViewCell.h
-
-(void)layoutSubviews {
self.frame = //Define your frame;
[super layoutSubviews];
}