我有一个UIScrollView,可以通过滑动来显示新的视图。我有一个按钮,我希望通过编程的方式滚动视图。因此,如果我点击一次它,它将滚动到下一个视图。我该如何实现这个功能?
以下是UIScrollView的代码:
以下是UIScrollView的代码:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)aScrollView
{
NSUInteger offset = aScrollView.contentOffset.x;
NSUInteger width = aScrollView.contentSize.width;
int anIndex = (offset == 0) ? 0 : (int)(width/(width - offset));
selectedDeal = [deals objectAtIndex:(anIndex > [deals count]- 1 ? [deals count]- 1 : anIndex)];
}