简体   繁体   中英

how to scroll tableview on Page control in iOS

I want to scroll tableview on Page control or when it is scrolled horizontally but when user is on 1st page i want to show 3 records then when user scroll for next page i want to show next 3 records & so on. How to do this .currently i am not able to understand how should i show next 3 records when user scroll for next page?

below method will get called when you try to scroll the page(page control), so in this method set content offset of your table view.Just set Y axis .you can set any value in y axis, it is upto you. so whenever you try to scroll the page, the tableview will be automatically scrolled vertically.

   -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  {
      int page=scr.contentOffset.x / scr.frame.size.width;
      [pageMap setCurrentPage:page];
      yourtableview.contentOffset=CGPointMake(0, 25);//you can set any value in y axis
  }

let me know it is working or not!!!

Happy Coding!!!!

Scroll table view

This code might help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM