Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content Offset animation broken

I have an animation which is kicked off when a gesture recogniser (double tap) fires:

[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);            
}];

It's working nice except in one case : if scrollViewWillBeginDecelerating delegate method is not called before animation execution (just by dragging hardly my scrollview).

I just have scrollViewDidEndDragging method called.I can wait 20 sec and then play my animation. It'll play correctly except for my contentOffset.

The delegate methods themselves do nothing, they were only added to see where the problem might be.

I have no idea why.

Edit : here's a video of my problem. Phase 1 : scroll with deceleration and phase 2 without. Look a the final position. Phase 1 is correct but not phase

like image 468
Pierre Avatar asked Mar 05 '14 14:03

Pierre


1 Answers

try:

[_scrollView setContentOffSet:CGPointMake(x, y) animated:YES];

outside of the animation block. I don't believe contentOffSet is animatable through UIView's animation block.

Edit: Instead of:

_scrollview.contentOffSet = CGPointMake(x, y);

try:

_scrollview.bounds = CGRectMake(x, y, CGRectGetWidth(scrollview.bounds), CGRectGetHeight(scrollview.bounds));
like image 192
Murillo Avatar answered Oct 04 '22 21:10

Murillo