我在UIScrollView
有5个页面的示例代码。当S滚动UIScrollView
页面更改时。并将pageControl
放在示例代码中。但我想滚动UIScrollView
而不滚动它。与NSTimer
类似,它会自动滚动。
答案 0 :(得分:1)
1-时间表NSTimer
// fire every second
self.scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
2-火上滚动一页
- (void)timerFired
{
CGFloat pageSize = scrollView.contentSize.width / scrollView.frame.size.width;
// if this is the last page return
if(scrollView.contentOffset.x >= scrollView.contentSize.width) {
[scrollView setContentOffset:CGPointMake(0.0, scrollView.contentOffset.y) animated:YES];
} else {
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x + pageSize, scrollView.contentOffset.y) animated:YES];
}
}
答案 1 :(得分:0)