How to auto scroll UIScrollView using timer?

后端 未结 5 496
粉色の甜心
粉色の甜心 2020-12-08 11:29

I have a UIScrollView to show images. I need a timer to show the images one after another, after every 5 seconds. How to initiate UIScrollView even

5条回答
  •  误落风尘
    2020-12-08 11:46

    to get current value as w (x value) or h (y value) of content. This helps with manual/semi automatic scrolling with the current reference point in your content of your UIScollView.

    CGFloat w = scroller.contentOffset.x;
    

    or

    CGFloat h = scroller.contentOffset.y;
    

    then of course:

    h += 100; // h-=100 for decrement
    yourScrollView.contentOffset = CGPointMake(0, h);  
    

提交回复
热议问题