Reputation: 1853
how can i get the x position of the contentOffset?
here´s my code but that throws always 0 in the log
- (void)adjustAreaScroll:(NSNotification *)notification
{
int value = [[notification object] intValue];
NSLog(@"adjustAreaScroll, %i", value);
switch (value) {
case 0:
[topScroll setContentOffset:CGPointMake(0, 0)];
break;
case 1:
[topScroll setContentOffset:CGPointMake(1024, 0)];
break;
case 2:
[topScroll setContentOffset:CGPointMake(2048, 0)];
break;
case 3:
[topScroll setContentOffset:CGPointMake(3072, 0)];
break;
}
NSLog(@"target position -----> %i", self.topScroll.contentOffset.x);
}
Upvotes: 2
Views: 7768
Reputation: 23271
NSLog(@"Offset : %@", NSStringFromCGPoint(scrollview.contentOffset.x));
or Define as like this
CGFloat offSet= scrollview.contentOffset.x;
NSLog(@"Offset : %f", offset);
Upvotes: 1
Reputation: 2781
CGPointMake returns a CGPoint, which is made of CGFloats. Make the %i into %f.
Upvotes: 5