i download json data , populate custom uitableview, problem if calculate height of tableview based on amount of elements download cells doesn't fit whole height of tableview, final situation tableview n elements has height of n*100 cells fits part of it. code used calculate height:
//callback contains items download -(void)productsdownloaded:(nsarray *)items { _productsdetails = items; cgfloat height = 100; height *= items.count; cgrect tableframe = _customtableview.frame; tableframe.size.height = height; _customtableview.frame = tableframe; [_customtableview reloaddata]; }
i tried:
_customtableview.alwaysbouncevertical = no; _customtableview.scrollenabled = no;
but no results.. how can tell cells fit height of cell?
to achieve scrollable table view, have use tableview:heightforrowatindexpath:
delegate method specify size (height) or cell, not change frame of table view.
example:
- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { //todo: calculate cell height return 60.0f; }
to have cells visible on 1 screen, total height of table view cells has equal height of table view, height of 1 table view cell should be:
cgfloat cellheight = cgrectgetheight(tableview.frame) / numberofcells;
however, don't understand why want this. whole reason of table view have fixed height cells , scroll (like settings app it).
Comments
Post a Comment