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
event to move to the next image after 5 seconds using the timer?
To use you just need to press CTRL+ Left click of your mouse and drag the mouse a bit in the direction you want to scroll the page. For example, if you want to scroll up to the page automatically, click CTRL+ left click and slightly move your mouse upwards, the tool will start scrolling up the page.
Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.
The autoscroll timer runs at 100ms (assuming a default double-click speed of 500ms), and if the mouse move message is generated after, say, 25ms, then the autoscroll should move only a quarter of its usual distance, rather than the full distance.
To scroll by dragging the mouse pointer beyond the edge of the current window or screen. It is used to move around a virtual screen as well as to highlight text blocks and images that are larger than the current window.
Add the variable int h to your interface, and yourScrollView as a property. Then:
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
- (void) onTimer {
// Updates the variable h, adding 100 (put your own value here!)
h += 100;
//This makes the scrollView scroll to the desired position
yourScrollView.contentOffset = CGPointMake(0, h);
}
modifying the above code
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
-(void) onTimer {
// NSLog(@"content offset %f",scrollVw.contentOffset.y);
if (scrollVw.contentOffset.y<MAX_ALLOWED_OFFSET) {
//scroll to desire position
scrollVw.contentOffset = CGPointMake(0, scrollVw.contentOffset.y+1);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With