2 UIScrollView检测当前页面并加载正确的页面
问题的第一部分:检测滚动视图 A 和 B 中显示的当前图像
我想在主视图中放置两个 UIScrollView。非常简单地完成了。所以我把 UIScrollView A 放在 UIScrollView B 上面。 所以它看起来像这样:
Graphical representation
________
| A | ScrollViewA is above ScrollViewB
|______|
| B | ScrollViewB is below ScrollViewA
|______|
用户可以在两个 ScrollView 上左右滑动图像。 它们都显示不同的图像集。
首先我想知道如何检测两个滚动视图所在的图像。对于A和B。
所以我应该能够检测哪些图像正在scrollviewA和scrollview B上显示 例如:UIScrollView A 在图像 12 上,UIScrollView B 在图像 67 上。
问题的第二部分:当用户从左和右滚动时在两个滚动视图上加载图像
因为 ScrollViewA 中会有很多图像用户可以从左向右滚动; ScrollViewB 中的许多图像用户也可以从左向右滚动;显然我不想将它们全部加载到滚动视图中。我可以在滚动视图中加载它们的最佳方式是什么?
一个想法是,如果用户在图像 5 上,那么用户向左滑动,那么下一个图像将是 6,因此仅加载该图像。等等。
每个人都可以帮助我如何实现这样的事情吗?谢谢。 您的所有想法和帮助将不胜感激。
First part of the question: Detecting current images being displayed in scrollview A and B
i want to place two UIScrollViews in my main view. Very simply done. So ive placed UIScrollView A above UIScrollView B.
so it looks like this:
Graphical representation
________
| A | ScrollViewA is above ScrollViewB
|______|
| B | ScrollViewB is below ScrollViewA
|______|
There will be images which the user can flick through left and right on both ScrollViews.
They both show different set of images.
First i want to know how to detect which image the both scrollviews are on. for both A and B.
so i should be able to detect which images are being displayed on scrollviewA and scrollview B
eg: UIScrollView A is on image 12 and UIScrollView B is on image 67.
Second part of the question: Loading images on both scroll view as user scrolls from left and right
Because there will be many images in ScrollViewA that the user can scroll from left to and right; and many images in ScrollViewB that the user can also scroll from left to right; obviously i dont want to load them all into the scroll view. Whats the best way i can load them in a scrollview?
an idea is if a user is on image 5, then the user flicks to the left, then the next image will be 6 so only load that image. and so on.
Can everyone help me on how to implement such a thing. Thank you.
All your ideas and help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
加载图像时,您可以执行以下操作:
这样,滚动视图一次只会加载 3 个。
在跟踪加载了哪个图像时,您必须自己跟踪它。
On loading images, you can do this:
This way you will only have 3 loaded at a time for a scrollview.
On keeping track of which image is loaded, you have to keep track of that yourself.