我正在尝试使用新的scrollViewWillEndDragging:withVelocity:targetContentOffset:iOS 5中的UIScrollView委托调用,但我似乎无法让它真正正确地回应我.我正在更改targetContentOffset-> x值,但它永远不会被使用.我知道代码正在运行,因为它会在该函数中命中断点.我甚至尝试将偏移值设置为硬编码数字,因此我知道它最终会在哪里但它永远不会起作用.
有没有人能够正确使用它并使其工作?是否有任何其他委托调用必须实现才能使其工作?
这是我的代码,万一有人看到它有问题:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
// goodOffsetX returns the contentOffset i want the scrollView to stop at
CGFloat goodOffsetX = [self _horizontalContentOffsetForTargetHorizontalContentOffset:(*targetContentOffset).x velocity:velocity.x];
NSLog( @" " );
NSLog( @"scrollViewWillEndDragging" );
NSLog( @" velocity: %f", velocity.x );
NSLog( @" currentX: %f", scrollView.contentOffset.x );
NSLog( @" uikit targetX: %f", (*targetContentOffset).x );
NSLog( @" pagedX: %f", goodOffsetX );
targetContentOffset->x = goodOffsetX;
}
Run Code Online (Sandbox Code Playgroud)