ios - How do i automatically scroll in a table view? (Swift) -


i added search bar table view, , user searches, want table view scroll text typed.

how make scroll view scroll automatically?

this tried, error saying integer not convertible index path. should do?

self.tableview.scrolltorowatindexpath(1, atscrollposition: uitableviewscrollposition.middle, animated: true) 

or

self.tableview.scrolltonearestselectedrowatscrollposition(scrollposition: uitableviewscrollposition.middle, animated: true) 

you have call method scrolltorowatindexpath in following way :

var indexpath = nsindexpath(forrow: numberofrowyouwant, insection: 0) self.tableview.scrolltorowatindexpath(indexpath,                 atscrollposition: uitableviewscrollposition.middle, animated: true) 

the above example assume have 1 section. hope you.

for swift 3:

let indexpath = nsindexpath(item: numberofrowyouwant, section: 2) tableview.scrolltorow(at: indexpath indexpath, at: uitableviewscrollposition.middle, animated: true) 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -