創建的.xib:的UITableViewCell大小不合適
設置類:
這是怎麼顯示:
這是我的方式OAD細胞:
@implementation FieldInfoTableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UINib *cellNib = [UINib nibWithNibName:@"FieldInfoCell" bundle:nil];
[self.tableView registerNib:cellNib forCellReuseIdentifier:FieldInfoCellIndentifier];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
FieldInfoCell *fieldCell = [tableView dequeueReusableCellWithIdentifier:FieldInfoCellIndentifier forIndexPath:indexPath];
fieldCell.fieldNameLabel.text = self.boundarier.name;
return fieldCell;
}
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
FielcInfoCell:
@interface FieldInfoCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *fieldNameLabel;
@end
@implementation FieldInfoCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
標籤被重命名,但細胞的大小和背景顏色都未被設置。
編輯:
我設置IB高度:
補充說:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 150;
}
也練就了我的高度,但仍然沒有背景色。有點讓我覺得我沒有正確設置別的東西。
你在UITableView的在IB設置單元格的高度?或者在tableView:heightForRowAtIndexPath委託方法中? – 2013-05-13 21:45:01