我希望UIScrollView总是回滚到特定点。我已经做到了这一点:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
(*targetContentOffset).x = 0.0f;
}它工作得很好,只有一个例外。当我滚动到足够远的地方,到达视图的末端(然后弹跳开始)并向上拉我的手指时,视图只是平滑地滚动,减速稍微向后一点,然后停止,然后跳到我设置的地方(没有动画)。只要我不滚动到滚动视图的末尾,它就不会发生。
下面是我初始化UIScrollView的方法
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 284, frame.size.height)];
scrollView.backgroundColor = [UIColor clearColor];
scrollView.delegate = self;
[scrollView setContentSize:CGSizeMake(285,frame.size.height)];
[self addSubview:scrollView];
UIEdgeInsets inset = scrollView.contentInset;
inset.left = 60;
inset.right = 60;
[scrollView setContentInset:inset];发布于 2012-07-11 21:53:09
弹跳效果是一种默认行为当您到达scrollview的内容边界时,可以通过将bounces属性设置为NO将其关闭
yourscrollView.bounces = NO;我相信这只是你在这里面临的问题。
发布于 2018-10-11 21:21:01
6年后,弹跳动画和targetContentOffsetForProposedContentOffset方法之间仍然存在这种冲突……
https://stackoverflow.com/questions/11433522
复制相似问题