[英]App like default photo browser in iphone?
i am developing a app which contains feature like default photo browser in iphone. 我正在开发一个应用程序,其中包含iPhone中默认照片浏览器之类的功能。 I done some what similar to that.
我做了一些类似的事情。 but after loading some(near about 10-15) images from remote server,i am receiving memory warning.My requirement is loading image one by one.
但是从远程服务器加载了一些(大约10-15张)图像后,我收到了内存警告。我的要求是一张一张地加载图像。 For this, on scroll view i am putting an images and increasing the contentSize of scroll view.
为此,在滚动视图上我要放置图像并增加滚动视图的contentSize。 it will work fine.
它将正常工作。 but due to memory warning app quite.
但由于内存警告应用程序相当。
Guys, any have any idea to approach for this feature which work similar to photo app without problem? 伙计们,有没有什么想法可以使用此功能,而该功能类似于照片应用程序却没有问题?
thanks in advance . 提前致谢 。
You're running out of memory because you're keeping the data for 10 or more images in memory at one time. 您用完了内存,因为您一次将10个或更多图像的数据保留在内存中。 You need to have more logic in your code that not only preloads and increases the scroll view's content size, but also removes UIImageViews from the scrollview (and thus from memory) as the user scrolls to newer stuff.
您需要在代码中拥有更多的逻辑,这些逻辑不仅可以预加载和增加滚动视图的内容大小,而且还可以在用户滚动到新内容时从滚动视图(从而从内存)中删除UIImageViews。 (You can also save "evicted" images to the cache area on disk so if the users scrolls back you don't have to go to the server again.)
(您还可以将“已删除”的图像保存到磁盘上的缓存区域,因此,如果用户向后滚动,则无需再次访问服务器。)
If you use a UITableView, it will request the images only when needed, and will automatically purge off-screen cells to save memory. 如果使用UITableView,它将仅在需要时请求图像,并且将自动清除屏幕外的单元以节省内存。 It may not fit into the aesthetic for your application, though.
但是,它可能不适合您的应用程序的美学要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.