ios - Want UITableView to "snap to cell" -
i displaying large images in uitableview
. user scrolls, i'd table view snap center-most photo in middle. is, when table in resting state, have uitableviewcell
snapped center.
how 1 this?
you can use uiscrollviewdelegate
methods on uitableview
this:
- (void)scrollviewdidenddragging:(uiscrollview *)scrollview willdecelerate:(bool)decelerate { // if decelerating, let scrollviewdidenddecelerating: handle if (decelerate == no) { [self centertable]; } } - (void)scrollviewdidenddecelerating:(uiscrollview *)scrollview { [self centertable]; } - (void)centertable { nsindexpath *pathforcentercell = [self.tableview indexpathforrowatpoint:cgpointmake(cgrectgetmidx(self.tableview.bounds), cgrectgetmidy(self.tableview.bounds))]; [self.tableview scrolltorowatindexpath:pathforcentercell atscrollposition:uitableviewscrollpositionmiddle animated:yes]; }
Comments
Post a Comment