我正在尝试实现 UIScrollView,但我想为 ScrollView 设置动画以每 10 秒显示一次 ScrollView 的不同 View 。对于我发现的这种方法可能有所帮助:
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
但是你们有谁知道是否有一种方法可以根据时间实现 ScrollView 的更改?
最佳答案
你可以使用
[NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:@selector(updateScrollPosition:)
userInfo:nil
repeats:YES];
然后在 updateScrollPosition
中,您可以相应地更新 scrollView 的偏移量。
-(void)updateScrollPosition{
[scrollView setContentOffset:contentOffset animated:YES];
// where contentOffset is the custom CGPoint
// where you want your scrollView to scroll after every 10 sec
}
关于ios - UIScrollView 根据时间改变位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33353969/