简体   繁体   English

其中启用了分页的UIScrollView和UIImage

[英]UIScrollView and UIImage in it with paging enabled

I need to display 10 - 1000 images on a UIScrollView. 我需要在UIScrollView上显示10-1000张图像。 Paging is enabled. 分页已启用。 So every page of the scrollview is an image, it is an uiimage. 因此,scrollview的每个页面都是一个图像,它是一个uiimage。 I can load 10 images to 10 uiimages which stays in the memory, but with 1000 images I have problems on the iPhone or on the iPad. 我可以将10张图像加载到内存中保留的10张uiimages中,但是使用1000张图像时,我在iPhone或iPad上遇到问题。 I am trying to unload and then load the images when I am doing scrolling. 我在尝试滚动时尝试卸载然后加载图像。 I every time displays 3 images. 我每次显示3张图片。 The current page image, and the -1 and +1 pages. 当前页面图像以及-1和+1页面。 When I am scrolling I unload the image and then load the next. 滚动时,我卸载图像,然后加载下一张图像。 With this method I have two problems. 使用这种方法,我有两个问题。 The scrolling is laggy and if I scroll very fast the images don't appear. 滚动很慢,如果我快速滚动,则图像不会出现。 Maybe is there any good solution for these problems? 也许对于这些问题有什么好的解决方案? Can you suggest me one? 你能建议我一个吗?

You should use a table with large custom cells each containing one image view. 您应该使用包含大量自定义单元格的表,每个单元格包含一个图像视图。 That way you never have more than a few image views in existence at anyone time. 这样一来,您在任何时候都不会拥有多个图像视图。 The table will manage swapping out the images that should be visible for you so you don't have to write all that code yourself. 该表将管理掉对您来说应该可见的图像,因此您不必自己编写所有代码。

However, even with a table you will get poor performance if you try to display 1,000 large (say 20%+ of screen size) images. 但是,即使使用桌子,如果尝试显示1,000张大(例如屏幕尺寸的20%以上)的图像,也会导致性能下降。 I haven't tried this on the iPad but the iPhone just doesn't have the horsepower and memory to handle that many images quickly. 我没有在iPad上尝试过这种方法,但iPhone却没有足够的能力和内存来快速处理这么多图像。

Instead, you should copy the Photo Library's hierarchical system. 相反,您应该复制照片库的分层系统。 Present thumbnails and then a detail view for the full image or a side to side scrolling detail view that only shows one image at time. 呈现缩略图,然后显示完整图像的详细信息视图或一次仅显示一个图像的左右滚动详细视图。 This has the added advantage of being an interface the user is already perfectly familiar with. 这具有成为用户已经非常熟悉的界面的附加优势。

three20项目中的TTPhotoViewController也许会有用。

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

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