UITableView 不会滚动到某个位置
[self.tableView setContentOffset:CGPointMake(0,48) animated:NO];
我有一个 UITableView,标题中有一个 UIView。我的 UITableView 不会滚动到 (0,48),除非动画:是。我不想让它动画化。
有谁知道怎么回事吗?
[self.tableView setContentOffset:CGPointMake(0,48) animated:NO];
I have a UITableView that has a a UIView in the header. My UITableView won't scroll to (0,48) unless animated: YES. I don't want it to animate.
Anyone know whats up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要设置节标题的 UIView,您正在使用函数:
我怀疑您在 viewWillAppear 中的某处调用 setContentOffset,但该函数稍后会调用。我认为它会覆盖你的 contentOffset。 ...不知道为什么当动画为 YES 时它不会,但无论如何,只需将您的 setContentOffset 放入此函数中,如下所示:
为我工作,希望对其他人也如此。
To set the UIView for the section header, you're using function:
I suspect you invoke setContentOffset somewhere in viewWillAppear, but that function is called later. And I think it overwrites your contentOffset. ...not sure why it doesn't when animated is YES, but anyway, just put your setContentOffset into this function like this:
Worked for me, hope so will for somebody else.
您可以尝试名为 -scrollRectToVisible:animated 的方法。
我误解了你的问题。那么,您想要的是将 y 坐标偏移约 48 像素来初始化 tableview 吗?
这将使 tableView 从 yPos 48 开始。
希望这可以帮助你......
You can try the method named -scrollRectToVisible:animated.
I misunderstand your question. So, what you want is to initialize the tableview with a shift of y-coordinate about 48 pixels ?
This will make the tableView begin from yPos 48.
Hope this can help you....