UIScrollView paging slow animation

I have an application i'm currently developing for iOS which is suffering from some performance issues. The app takes user input through a navigation controller with 5 views, the last view generates a view with a UIScrollView which has a paging effect. Each page in this UIScrollView has 16 buttons arranged in a grid, each of these buttons is loaded with an image.

Unfortunately when I scroll to a new page in the UIScrollView, the app stumbles across in a jerky animation rather than a smooth one.

I was wondering if anyone had any suggestions on how to improve the performance for the paging UIScrollView effect.

Many thanks.


Is it smoother the second time you navigate to that view?

If so, it's probably the loading of the images that is taking the time. You can fix that by preloading your button images when the app first loads using [UIImage imageNames:...] in your app delegate. That way they will already be cached and available to render when the view is displayed.

If it's not faster the second time, it's probably the actual rendering of the views that is too slow. You can fix that by preloading the views themselves. If you store a reference to your scrollview's subviews in an array, you can preload those views in your app delegate and just keep them in memory ready to display whenever the scrollview is shown.

I doubt that those views will use up too much memory (probably a couple of MB, max), but if you are worried about it, just add a memory warning handler that flushes out the array and then re-create it next time it's needed.

链接地址: http://www.djcxy.com/p/39472.html

上一篇: 如何开发或迁移iPhone 5屏幕分辨率的应用程序?

下一篇: UIScrollView分页慢动画