Change page on UIScrollView

后端 未结 12 1323
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 18:45

I have a UIScrollView with 10 pages. I am able to flick between them. I also want to have 2 buttons (a back button and a next button) which when touched will go to the previ

12条回答
  •  Happy的楠姐
    2020-12-04 19:36

    Additional to this code that mjdth added, remember to place it in the viewWillAppear or viewDidAppear.

    CGRect frame = scrollView.frame;
    frame.origin.x = frame.size.width * pageNumberYouWantToGoTo;
    frame.origin.y = 0;
    [scrollView scrollRectToVisible:frame animated:YES];
    

提交回复
热议问题