【发布时间】:2015-05-15 05:53:30
【问题描述】:
当 UIScrollView 到达其内容视图的末尾时,我有以下代码来获取事件:
- (void) scrollViewDidEndDecelerating:(UIScrollView *) scrollView
{
float currentEndPoint = scrollView.contentOffset.y + scrollView.frame.size.height;
// CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
// [scrollView setContentOffset:bottomOffset animated:NO];
if (currentEndPoint >= scrollView.contentSize.height)
{
// We are at the bottom
我注意到,当我滚动到底部时,它会碰到它并弹回。
如果我添加这个:
CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
[scrollView setContentOffset:bottomOffset animated:NO];
然后滚动回到底部。
有没有办法让它保持在底部而不会“反弹”,就像一旦它触到底部,就停止移动。
谢谢。
【问题讨论】:
-
您可能需要使用
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset而不是scrollViewDidEndDecelerating:?
标签: ios objective-c ios8 uiscrollview setcontentview