Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a grid of icons like the iPhone home screen?

How should I go about creating a UI similar to the Springboard (home screen) on the iPhone? I'd like a grid of evenly spaced buttons with images where I can respond to the button tap.

Is the UITable a good fit? Should I use a plain UIView and position the icons manually in DrawRect? Is there an alternative that will automatically evenly space the buttons, allow reorganization, and adjust the layout according to the iPhone orientation?

I come from a C#/Winforms background and am just now starting iPhone development on the Open Toolchain with 2.2.1 headers.

like image 504
Nick VanderPyle Avatar asked Feb 03 '09 17:02

Nick VanderPyle


1 Answers

I've written some sample code to do something like this. See my Tiles blog entry, or just download the code: Tiles-v1.0.zip.

My code creates the icons as Core Animation layers, not as UIViews, but does demonstrate how to detect taps and allow reorganization of the icons. It doesn't handle orientation changes.

like image 164
Kristopher Johnson Avatar answered Oct 02 '22 13:10

Kristopher Johnson