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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -