iPhone动态滚动视图的问题

发布于 2024-10-10 18:13:11 字数 273 浏览 2 评论 0原文

我在网上寻找我的问题的答案,但没有成功。我正在使用带有 3 个按钮的工具栏的视图。在一个视图中是一个滚动视图。每当我点击其中一个按钮时,滚动视图就会填充许多具有动态大小和位置的标签和文本视图。取决于解析的文本量。滚动视图的大小(高度)也会根据其子视图的大小动态变化。当我只需切换工具栏按钮而无需事先滚动视图时,一切都很好。但是,如果我将视图滚动到底部,然后通过单击按钮更改文本和标签的位置和大小,滚动视图会表现得很奇怪,并且不会返回到其先前的位置(内容偏移 0, 0)。我想知道是否有一个好的 waz 可以使这项工作更加顺利。谢谢!

I was looking for an answer to my problem all over the net but with no succes. I am using a view with a toolbar with 3 buttons. In a view is a scrollview. Whenever i tap one of the buttons, scrollview is populated with a number of labels and textviews with dynamic size and position. depending on the ammount of text that was parsed. The size of scroll view (height) is also dynamicly changed depending on the size of its subviews. It all works good when i just switch toolbar buttons without previously scrolling the view. But if i scroll a view to the bottom, and then by clicking button i change positions and size of text and labels, the scrollview is acting strange and is not returning to its previous position (content offset 0, 0). I was wondering if there is a good waz to make this work more smootly. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙与沫 2024-10-17 18:13:11

为什么不简单地在设置滚动视图的新内容的同时设置其 contentOffset ,即

// populate your scrollView and set its contentSize
// ...
[yourScrollView setContentOffset:CGPointZero animated:YES];

Why don't you simply set the contentOffset of the scroll view at the same time you are settings its new content, i.e.

// populate your scrollView and set its contentSize
// ...
[yourScrollView setContentOffset:CGPointZero animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文