UIImageView 中的简单幻灯片
我在将幻灯片添加到我的应用程序时遇到了麻烦。
目前,我有一个由分段控件组成的 UIView。 我制作了两个“视图”,根据所选按钮隐藏或显示它们。
我希望在我的两个视图之一中制作一个简单的幻灯片。我做了一个UIImageView,因为显示图片简单。
所以我想一张一张地显示我的照片,并且可以通过向右或向左滑动手指从一张图像移动到另一张图像(就像在本机应用程序“照片”中一样)。
我尝试改编文档中的示例代码,但没有成功。
所以我要寻求帮助。
谢谢, 新山克雷斯托
I got trouble to add slideshow to my application.
Currently, I have a UIView composed of a segmentedControl.
I made two "views" that I hide or display depending on the selected button.
I'm looking to make a simple slideshow in one of my two views. I made a UIImageView because it is simple to display pictures.
So I'd like to display my pictures one by one and it is possible to move from one image to another by sliding your finger to the right or left (just as in the native app "Photos").
I tried to adapt example codes from the documentation, but without succes.
So I'ml looking for help.
Thanks,
jb crestot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
所以,我实际上已经做到了这一点,而且相当简单。您缺少的成分是 UISCrollView。我的实现完全按照您的描述进行(允许用户在一组图像之间来回切换)。
基本上,将 UIScrollView 添加到界面生成器中的视图中,您将使用代码(一个简单的 for 循环)创建 UIImage 视图,并以相同的方式设置它们的图像。我安全地完成了大约 15 张图像(PNG),没有出现任何记忆问题。如果您正在处理大量图像(例如 40 个?),此消息可能会存在潜在的性能问题。
我希望这会有所帮助,如果您需要代码示例来了解其工作原理,请告诉我。
SO, I've actually done this and it's fairly easy. The ingredient that you are missing is a UISCrollView. My implementation did exactly what you describe (allow the user to go back and forth between a set of images).
Basically, add a UIScrollView to your View in interface builder and you will be creating the UIImage views with code (a simple for loop) and setting their images the same way. I did this safely with no memories issues with about 15 images (PNG's). There could be a potential performance issue with this message if you are working with a large number of images (say 40?)
I hope this helps, let me know if you need a code sample to see how this works.
您可以考虑使用自定义类,例如下面链接的 iCarousel。例如,每个视图都可以是您的图像,然后点击它们可以启动全屏视图。
请随时通知我们!
http://cocoacontrols.com/platforms/ios/controls/icarousel
You may consider using a custom class, such as iCarousel, linked below. Each of these views could be your image, and then tapping on them could launch a fullscreen view for example.
Keep us posted!
http://cocoacontrols.com/platforms/ios/controls/icarousel
请参阅苹果的页面控制示例应用程序。
See apple's page control sample application.