使用UIScrollView在多个图像之间水平滚动 [英] Scrolling horizontally between multiple images using UIScrollView

查看:122
本文介绍了使用UIScrollView在多个图像之间水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们从照片应用程序开始,例如。可以通过滑动查看图像,并且当用户滑动时图像滚动到视图中。

If we start with the photos app for example. The images can be viewed with a swipe and the images scroll into view as the user swipes.

这种UIScrollView设置如何以及如何在UISCrollView中显示图像(例如从数组中)?

How is this kind of UIScrollView setup and how are the Images (e.g. from an array) displayed within this UISCrollView?

图像是否立即添加到滚动视图中或者如何实现这种分页?

Are the images added to the scrollview at once or how is this paging look achieved?

谢谢

推荐答案

这可以使用主 UIScrollView 实现, pagingEnabled 设置为 YES 并包含嵌套的 UIScrollViews 。然后你可以在每个嵌套的滚动视图中放置一个 UIImageView ,这样你也可以通过将它返回到 - (UIView *)viewForZoomingInScrollView来实现缩放。 :

This can be achieved using a main UIScrollView with pagingEnabled set to YES and containing nested UIScrollViews. Then you can put an UIImageView in each one of these nested scroll views, so you can also achieve zooming by returning it to - (UIView *)viewForZoomingInScrollView:

此外,您还可以查看Apple的这些样本:

Also, you can take a look at these samples from Apple:

http://developer.apple.com/library/ios/#samplecode/Scrolling /Introduction/Intro.html

http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/Introduction/Intro.html

这篇关于使用UIScrollView在多个图像之间水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆