ios - How to make pagination in tableView? -
i have implemented tableview in app, have large number of data, want show data in pagination, means 10 rows in 1 screen, user can paginate , show 10 rows in next screen.
paging means want scrolling
is possible using existing component? or have create custom controller? if process it?
var allobjectarray: nsmutablearray = [] var elements: nsmutablearray = [] var currentpage = 0 var nextpage = 0 override func viewdidload() { super.viewdidload() var = 0; <= 500; i++ { allobjectarray.addobject(i) } elements.addobjectsfromarray(allobjectarray.subarraywithrange(nsmakerange(0, 20))) } override func tableview(tableview: uitableview, willdisplaycell cell: uitableviewcell, forrowatindexpath indexpath: nsindexpath) { println(indexpath.row) nextpage = elements.count - 5 if indexpath.row == nextpage { currentpage++ nextpage = elements.count - 5 elements.addobjectsfromarray(allobjectarray.subarraywithrange(nsmakerange(currentpage, 20))) tableview.reloaddata() } }
download sample code here.
Comments
Post a Comment