Get currentOffset and ZoomScale during animation?

Hello, first sorry for my poor english.


I have developed a Gigapixel Visor with UIScrollView, using CALayer for tiles, Currently is working with user interaction (dragging, zooming, etc), but I need reload the tiles when the Scroll is zooming or moving without user interaction


I have this code:


NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];

[UIView animateWithDuration:5.0

delay:0.0

options:UIViewAnimationOptionBeginFromCurrentState

animations:^{

[self.scroll zoomToRect:endZoom animated:NO];

}

completion:^(BOOL finished){

[self.scroll reloadTiles];

}];


- (void) onTimer

{

NSLog(@"%@",NSStringFromCGPoint(self.scroll.contentOffset));

NSLog(@"%f",self.scroll.zoomScale);

}


The problem: UIScrollView is returning the coordinates and scale from endZoom and not the intermediate coordinates and scale. I have tried with presentationLayer, but I can´t get the current scale, and the coordinates from presentationLayer is not precise enough. it´s possible?


Thanks.

Accepted Reply

Hello I tried this:


- (void) onTimer

{

NSLog(@"Zoom Scale:%f",self.zoomScale);

//Background is the subview of UIScrollview that return for zooming.

NSLog(@"Zoom Scale transform:%f",[[self.Background.presentationLayer.layer valueForKeyPath: @"transform.scale"] floatValue]);

}


The problem is that transform scale values are strange:

ScrollView Scale:1 PresentationLayer: 1

ScrollView Scale:2 PresentationLayer: 1.66667

ScrollView Scale:4 PresentationLayer: 3

ScrollView Scale:8 PresentationLayer: 5,66667

ScrollView Scale:16 PresentationLayer: 11

ScrollView Scale:32 PresentationLayer: 21.666666

ScrollView Scale:64 PresentationLayer: 43


Any idea?


EDIT: using transform.scale.x fixed this problem.

Replies

Hello I tried this:


- (void) onTimer

{

NSLog(@"Zoom Scale:%f",self.zoomScale);

//Background is the subview of UIScrollview that return for zooming.

NSLog(@"Zoom Scale transform:%f",[[self.Background.presentationLayer.layer valueForKeyPath: @"transform.scale"] floatValue]);

}


The problem is that transform scale values are strange:

ScrollView Scale:1 PresentationLayer: 1

ScrollView Scale:2 PresentationLayer: 1.66667

ScrollView Scale:4 PresentationLayer: 3

ScrollView Scale:8 PresentationLayer: 5,66667

ScrollView Scale:16 PresentationLayer: 11

ScrollView Scale:32 PresentationLayer: 21.666666

ScrollView Scale:64 PresentationLayer: 43


Any idea?


EDIT: using transform.scale.x fixed this problem.