【问题标题】:ScrollView contentOffset always count to zeroScrollView contentOffset 始终计数为零
【发布时间】:2014-03-22 15:53:03
【问题描述】:

我在我的应用程序中处理UIScrollView。我已经设置了 delegate ,但是当我在垂直向下方向滚动滚动视图时,它的 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]; 
}

谢谢

【问题讨论】:

  • 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]; }
  • [self.scrollView setContentSize:CGSizeMake(320, yAxis+100)];
  • 编辑你的问题,不要放在评论里
  • 这里没有响应滚动视图中滚动的内容。

标签: ios7 uiscrollview ios-simulator


【解决方案1】:

我也遇到过一模一样的问题,原来是我用错了NSLog。

原行:

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

应该是:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-23
    • 1970-01-01
    • 2016-05-02
    • 2012-01-16
    相关资源
    最近更新 更多