在iOS上创建网格视图 [英] Creating a grid view on iOS
问题描述
我需要使用动态变化的图像来实现网格视图。
I need to implement a grid view with dynamically-changing images.
大多数情况下,我使用 UITableView
创建一个网格,但如果我有大量图像,我会遇到内存问题。
Most of the time, I use a UITableView
to create a grid, but I run into memory issues if I have a large number of images.
在iOS 6中, UICollectionView
已添加,但我之前从未使用过它。
In iOS 6, the UICollectionView
was added, but I've never used it before.
制作网格时使用的最佳做法和视图子类是什么查看所以我没有内存问题?
What are some "best practices" and view subclasses to use when making a grid view so I don't have memory issues?
推荐答案
UICollectionView
,因此它无法使用如果你想支持早期版本,可以使用它。
UICollectionView
is available in iOS 6.0 and later, so it can't be used if you want to support earlier versions.
有很多开源库可以让你创建网格视图:
There are quite a open-source libraries that let you create grid views:
- KKGridView
- UIGridView
- AQGridView
- NRGridView
- MMGridView
- WCGridView
我目前正在使用 AQGridView
,我发现它是最多的强大的。它就像一个 UITableView
。 Evadne Wu创建了视频和示例项目显示如何使用它。
I am currently using AQGridView
, and I've found it to be the most robust. It works just like a UITableView
. Evadne Wu created a video and sample project showing how to use it.
此外,如果您尝试在不使用Interface Builder的情况下执行此操作,请记住,因为您将会更加困难必须以编程方式创建视图。
Also, if you're trying to do this without using Interface Builder, keep in mind that it'll be a bit more difficult since you have to create the views programmatically.
这篇关于在iOS上创建网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!