ios - Tableview showing the wrong size of cell -
this question has answer here:
in table setting height cell using(heightforrowatindexpath)delegate of table view code is:
-(cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { return 100; }
but checking size of cell in delegate method(cellforrowatindexpath) , code is:
- (uitableviewcell *)tableview:(uitableview *)atableview cellforrowatindexpath:(nsindexpath *)indexpath { // dequeue or create cell uitableviewcellstyle style = uitableviewcellstyledefault; uitableviewcell *cell = [atableview dequeuereusablecellwithidentifier:@"basecell"]; if (!cell) cell = [[uitableviewcell alloc] initwithstyle:style reuseidentifier:@"basecell"] ; cell.textlabel.text = [nsstring stringwithformat:@"cell %d", numberofitems - indexpath.row]; nslog(@"%f",cell.frame.size.height); return cell; }
when printing value(frame of cell)cell on console giving me 44.00.why happening setting height of cell..please explain me , cell oh height 100..thanks in advance
actually want make custom type table view support difrrent orientation of view , universal app better call cell size in behalf of checking every time (iphone/ipad,diff orintation)....plz me accomplish requirement
if cell being shown correctly, , correctly mean height of 100 pixels have written in tableview:heightforrowatindexpath:
, i'm pretty sure it's because you're asking cell's height in wrong place: cell has been init'd default init method, height returned therefore default one, of 44 pixels nslog prompts in console, on rendering delegate sets right height returned method , set correctly.
i had issue months ago, reasons needed know cell's height in tableview:cellforrowatindexpath:
method, came out workaround that: i've stored rowheights values in nsarray
, since dynamic , different row row according content.
i came out like
cgfloat height = [[heightsdata objectatindex: indexpath.section] objectatindex: indexpath.row];
Comments
Post a Comment