【问题标题】:content offset doesn't work内容偏移不起作用
【发布时间】:2016-01-12 03:07:35
【问题描述】:

我正在尝试在我的 uiscrollview 中设置内容偏移量。我尝试了以下方法,但没有一个有效。以下都不会以任何方式影响我的scrollView,它只是正常显示在屏幕上。:

 let point = CGPoint(x: 0, y: self.view.frame.height / 2)
 self.scrollView.setContentOffset(point, animated: true)

和:

 self.scrollView.contentOffset.y = self.view.frame.size.height / 2

和:

 self.scrollView.contentOffset = CGPointMake(0, self.view.frame.size.height / 2)

和:

 self.scrollView.contentOffset = CGPointMake(0, scrollView.frame.size.height / 2)

我的滚动视图是视图高度的 2 倍。它们基本上分为 2 个不同的视图,我可以在它们之间进行分页。我希望滚动视图从底部开始。

【问题讨论】:

  • 你把这些线放在哪里了?
  • 在 viewDidLoad 方法中

标签: ios swift uiscrollview


【解决方案1】:

你应该在viewDidLayoutSubviews试试他们

参考:iOS 9 scroll UITextView to top

【讨论】:

  • 你先生,救了我!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-04
  • 2016-05-04
  • 1970-01-01
相关资源
最近更新 更多