用户登录
用户注册

分享至

UIScrollView:单击将其滚动到顶部

  • 作者: 嗫?暁雲?
  • 来源: 51数据库
  • 2022-10-21

问题描述

我将 pagingEnabled 设置为 YES 的 UIScrollView,并以编程方式将其内容滚动到底部:

I have the UIScrollView with pagingEnabled set to YES, and programmatically scroll its content to bottom:

CGPoint contentOffset = scrollView.contentOffset;
contentOffset.y = scrollView.contentSize.height - scrollView.frame.size.height;
[scrollView setContentOffset:contentOffset animated:YES];

它滚动成功,但在那之后,单击它的内容会向上滚动以抵消它在向下滚动之前的偏移量.仅当我以编程方式将 scrollView 的内容滚动到底部然后点击时才会发生这种情况.当我滚动到任何其他偏移量然后点击时,什么都没有发生.

it scrolls successfully, but after that, on single tap its content scrolls up to offset that it has just before it scrolls down. That happens only when I programmaticaly scroll scrollView's content to bottom and then tap. When I scroll to any other offset and then tap, nothing is happened.

这绝对不是我想要的.应该如何解决?

That's definitely not what I'd like to get. How that should be fixed?

提前非常感谢!

帖木儿.

推荐答案

这似乎是一个错误:

UIScrollView 不记得位置

我已在 iOS 4.2(模拟器)上对此进行了测试,但问题仍然存在.

I have tested this on iOS 4.2 (Simulator) and the issue remains.

软件
前端设计
程序设计
Java相关