使用UIImageViews浏览页面/照片(类似于Facebook照片应用或主屏幕) [英] Flicking through pages / photos with UIImageViews (similar to Facebook photos app or home screen)

查看:64
本文介绍了使用UIImageViews浏览页面/照片(类似于Facebook照片应用或主屏幕)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想指出的是我不是在要求代码.我只是想问要使它正常工作我需要做的事情,因为现在我绝对不知道.这是我想做的:

First of all, I'd like to point out that I'm not asking for code. I'm just asking for the sort of things I'd need to do to get this to work, as right now I've absolutely no idea. Here's what I want to do:

类似于在Facebook应用程序中查看某人的照片,我想在屏幕上显示图像(UIImageView).当用户向左滑动(离开屏幕)时,会出现相册中的下一张照片(我想我可以使用某种图像阵列吗?).向右滑动可移动到相册中的上一张照片.

Similar to viewing someone's photos in the Facebook app, I'd like to display an image (UIImageView) on the screen. When the user flicks it left (off the screen), the next photo in the album appears (I guess I could use some sort of array of images?). Flicking right moves to the previous photo in the album.

我确定我能弄清楚正在加载图像和数组的内容,但是想到用轻弹动画将图像视图移出屏幕并显示系列中的下一张照片确实令人生畏.

I'm sure I could figure out the loading images and array stuff, but the thought of moving an imageview off the screen with a flick animation and showing the next photo in the series is really daunting.

如果您还没有使用Facebook应用程序,那么我得到的效果与在iPhone主屏幕上切换页面的效果相同.一旦将页面拖到目前为止,它将捕捉到下一页.任何帮助都将不胜感激.

If you haven't used the Facebook app, the effect I'm after is the same as switching pages on the home screen of the iphone. Once you drag the page so far, it snaps to the next page. Any help greatly appreciated.

推荐答案

您可以使用UIScrollView(将其pagingEnabled属性设置为YES)非常简单地执行此操作(只要您也没有实现缩放),和UIImageViews作为UIScrollView的子视图来显示图像,当然.

You can do this very simply (as long as you aren't implementing zoom as well) using UIScrollView with its pagingEnabled property set to YES, and UIImageViews as subviews of the UIScrollView to display your images, of course.

使用pagingEnabled == YES,UIScrollView会将其contentOffset捕捉为其边界的高度和宽度的倍数.

With pagingEnabled == YES, the UIScrollView will snap its contentOffset to multiples of its bounds' height and width.

http://developer.apple .com/IPhone/library/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html 查看全文

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