roc*_*lin 2 iphone objective-c uiscrollview ipad ios
我怎样才能获得contentOffset的x位置?
这是我的代码,但在日志中总是抛出0
- (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);
}
Run Code Online (Sandbox Code Playgroud)
CGPointMake返回一个CGPoint,它由CGFloats组成.将%i设为%f.