ios - Show only completely visible UITableViewCells -
i have custom tableview, way it's designed makes bottom , top part ugly when half of cell visible. see picture reference:
i want bottom part (and top after crolling) visible when can see 100% of cell.
i tried check if cells visible, believe cellforrowatindexpath creates reusablecells when it's partly visible , isn't called again when it's visible:
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var mycell:choosestorycell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! choosestorycell var cellrect = self.tableview.rectforrowatindexpath(indexpath) var completelyvisible = cgrectcontainsrect(self.tableview.bounds, cellrect) if completelyvisible == true { mycell.hidden = false mycell.backgroundcolor = color.sharedcolors().colorsarray[5] mycell.storylabel.text = stories[indexpath.row].name mycell.circleview.layer.cornerradius = 15 } else{ mycell.hidden = true }
how go forward this? appriciated!
put table view inside parent uiview. margin top of tableview top of parent view should equal height of cells is, same bottom, width of table view should same parent's view, left , right margins equals zero. there space @ top / bottom display cell.
on tableview set clipstobounds no, on parent view make sure clipstobounds set yes.
the behavior should this, when scrolling cell visible until reaches top boundary of parent view , disappear @ once.
alternatively, can reduce height of tableview, move down , set clipstobounds no. should it. prefer embed in view sure nothing display outside.
Comments
Post a Comment