ios - UItableViewCell not the right size -
creating .xib:
set class:
this how shows:
here how load cell:
@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 view selected state } @end
the label being renamed, cell size , background color not being set.
edit:
i set height in ib:
added:
-(cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { return 150; }
and gives me height, still no background color. kinda leads me think i'm not setting else correctly.
you can set tableview row height uitableviewdelegate:
- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{ return your_height; }
Comments
Post a Comment