触摸以在图像中移动

发布于 2024-11-27 09:07:09 字数 208 浏览 3 评论 0原文

我有一个 jpg 图像的 NSMutableArray,我希望能够触摸并从右向左移动手指,按顺序在图像数组中移动。我一直在阅读有关 UIScrollView 的内容,但我不确定这是否能满足我的要求。在我看来,UIScrollView更多地用于查看太大而无法完全显示在屏幕上的对象,并且您需要能够移动才能看到对象的每个部分。我需要移动到一个全新的图像,即数组中的下一个图像。解决这个问题的最佳方法是什么?

I have an NSMutableArray of jpg images and I want to be able to touch and, moving my finger from right to left, move through the array of images in order. I've been reading about UIScrollView, but I'm not sure if this accomplishes what I am looking for. It seems to me that UIScrollView is more used for viewing an object that is too large to be displayed entirely on the screen and you need to be able to move to see every part of the object. I need to move to an entirely new image, the next image in my array. What is the best way to go about this?

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

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

发布评论

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

评论(1

关于从前 2024-12-04 09:07:09

您当然可以使用UIScrollView 为你想要的。正如您所指出的,可以使用滚动视图来滚动对于屏幕来说太大的区域。但是,您也可以使用它来滚动“页面”。这确实是做你想做的事情的最好方法,除了滚动你赢得的滚动视图。

有一个属性 UIScrollView,名为 pagingEnabled,您需要将其设置为 YES。我建议你尝试一下。另外,请查看 UIScrollView 文档 和 < a href="http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/Introduction/Introduction.html" rel="nofollow noreferrer">滚动视图编程指南。它将告诉您有关 UIScrollViews 需要了解的所有信息。另外,请记住,为了正确管理内存,您在任何给定时间只需要加载三个图像。请参阅我写的这个答案以获取有关此问题以及一般 UIScrollViews 的更多信息。

You certainly can use a UIScrollView for what you want. A scroll view can be used, as you noted, to scroll an area that is too large for the screen. However, you can also use it to scroll through "pages". This is really the best way to do what you want, short of rolling your won scroll view.

There is a property of UIScrollView, called pagingEnabled, which you'll want to set to YES. I suggest that you give it a try. Also, have a look at the UIScrollView documentation and the Scroll View programming guide. It will tell you all that you need to know about UIScrollViews. Also, remember that for proper memory management, you'll want to only load three images at any given time. See this answer that I wrote for more information on that, and on UIScrollViews in general.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文