ScrollView contentOffset始终计为零

时间:2014-02-21 08:36:45

标签: ios7 uiscrollview ios-simulator

我在我的应用中处理UIScrollView。我已经设置了委托,但是当我在垂直向下滚动滚动视图时,它的contentOffset.y始终为零。我正在研究ios7模拟器。我不明白为什么会出现这个问题?有没有人有任何解决方案?

if (!scrollView) { 
    self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-70)]; 
    self.scrollView.backgroundColor = [UIColor whiteColor];
    self.scrollView.delegate = self;
    self.scrollView.contentOffset = CGPointMake(0, 0); 
    [self.view addSubview:self.scrollView]; 
}

由于

1 个答案:

答案 0 :(得分:-1)

我遇到了完全相同的问题,事实证明我使用了NSLog错误。

原始行:

NSLog("%d", scrollView.contentOffset.y)

应该是:

NSLog("%f", scrollView.contentOffset.y)

这真的是琐事,但希望这可以帮助像我一样在这里搜索的人。