简体   繁体   English

如何在iPhone应用程序中创建通过照片滑动功能

[英]how to create swipe through photos functionality in iPhone app

I want to be able to swipe through a series of images in my iPhone app like in the Photos app. 我希望能够像使用“照片”应用程序一样在我的iPhone应用程序中浏览一系列图像。 I want to have the pictures reside on the phone in the app itself. 我想让图片驻留在应用程序本身的手机上。

I know the facebook three20 api does this but it reads the images from a url. 我知道facebook three20 api可以做到这一点,但它会从URL中读取图像。

Does anyone know how I can implement this functionality? 有谁知道我如何实现此功能?

For creating the 'swipe through' functionality, you'll have you use a UIScrollView with horizontal scrolling. 为了创建“滑动通过”功能,您将使用带有水平滚动的UIScrollView The bounds of the UIScrollView should be set to the total available space, probably the whole screen ( CGRectMake(0, 0, 320, 480) ) and the contentSize should be the total width of the screens with images, so number of images * 320 . UIScrollViewbounds应设置为总可用空间,可能是整个屏幕( CGRectMake(0, 0, 320, 480)CGRectMake(0, 0, 320, 480) ),而contentSize应该是包含图像的屏幕的总宽度,因此number of images * 320 The height of this contentSize should be set to the height of the UIScrollView itself, so only horizontal scrolling is possible. contentSize的高度应设置为UIScrollView本身的高度,因此只能进行水平滚动。

For snapping to each image (so that would be every 320px) you can set the pagingEnabled property to YES (Thanks @Ben in the comments!) 为了捕捉到每个图像(因此每320px),您可以将pagingEnabled属性设置为YES (感谢@Ben!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM