Yasuhiro Kondo Yasuhiro Kondo - 5 months ago 28
iOS Question

How to use UIScrollview scroll to page when touch button

I want a UIScrollView that works like:

when I tap button "page1" scrollview will scroll to page 1

when I tap button "page2" scrollview will scroll to page 2

Any help thanks....

Answer

suppose the height value of your one page is pageHeight,

CGPoint contentOffset = yourScroll.contentOffset
contentOffset.y = pageHeight * pageIndex;
[yourScroll setContentOffset:contentOffset animated:YES];

hope this helpful