内容偏移动画已损坏

Pie*_*rre 6 objective-c uiscrollview ios contentoffset animatewithduration

我有一个动画,当手势识别器(双击)触发时,它会被踢掉:

[UIView animateWithDuration:0.3 animations:^{
  _scrollView.contentOffset              = CGPointMake(x, y);
  _scrollViewContentView.frame           = someFrame;
  _scrollViewContentView.layer.transform = 
       CATransform3DMakeScale(1.f/_zoomScale, 1.f/_zoomScale, 1.f);            
}];
Run Code Online (Sandbox Code Playgroud)

除了一种情况之外它工作得很好:如果scrollViewWillBeginDecelerating在动画执行之前没有调用委托方法(只是拖动几乎我的scrollview).

我只是有scrollViewDidEndDragging方法叫.我可以等20秒,然后播放我的动画.它会正常播放,除了我的contentOffset.

委托方法本身什么都不做,只是添加它们才能看出问题所在.

我不知道为什么.

编辑:这是我的问题视频.第1阶段:减速滚动,第2阶段没有.看看最后的位置.阶段1是正确的但不是阶段

Mur*_*llo 1

尝试:

[_scrollView setContentOffSet:CGPointMake(x, y) animated:YES];
Run Code Online (Sandbox Code Playgroud)

在动画块之外。我不相信 contentOffSet 可以通过 UIView 的动画块进行动画处理。

编辑:而不是:

_scrollview.contentOffSet = CGPointMake(x, y);
Run Code Online (Sandbox Code Playgroud)

尝试:

_scrollview.bounds = CGRectMake(x, y, CGRectGetWidth(scrollview.bounds), CGRectGetHeight(scrollview.bounds));
Run Code Online (Sandbox Code Playgroud)