我想在未拖动足够的情况下恢复我的UIScrollView的内容偏移:
回到原始位置的代码在else部分,它总是有效的。然而,当我滚动不够并且手势快速时,它会弹回。如果我只滚动一点点,然后将该位置保持略微长于平常的时间,它就能平滑地恢复。
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(CGPoint *)targetContentOffset {
self.endingOffset = scrollView.contentOffset;
if(abs(verticalOffset) > [self cellHeight] / 9) { // If the user scrolled enough distance, attempt to scroll to the next cell
...
} else if(self.nextCellOrigin.y != 0) { // The scroll view is still scrolling and the user didn't drag enough
...
} else { // If the user didn't drag enough
self.tableView.decelerationRate = UIScrollViewDecelerationRateNormal;
(*targetContentOffset) = self.startingOffset;
}
}
回到原始位置的代码在else部分,它总是有效的。然而,当我滚动不够并且手势快速时,它会弹回。如果我只滚动一点点,然后将该位置保持略微长于平常的时间,它就能平滑地恢复。
我在UIScrollView的API参考中没有找到用户触摸时间的任何信息,即使我找到了,也不清楚如何使用它来更改恢复代码的行为。我还尝试使用setContentOffset:animated:将滚动到的位置,但似乎无法解决抖动问题。
有什么想法吗?