Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a grid similar to iphone/ipads launcher screen?

I have seen a few grids made with UITableView but I don't really like how close together each cell is to the other. If there is a way of creating a grid system like the home screen on an iphone (the screen after it is unlocked) if would be great. I don't need an exact solution but a point in the right direction, maybe a set of libraries to look through would be great. I am running xcode 4.4.1

Thanks!

like image 367
Alfree92 Avatar asked Dec 04 '25 16:12

Alfree92


1 Answers

The key is UIScrollView has a paging mode (since could have more buttons than fit in the view). It's covered here's in Apple ocs:

http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/ScrollViewPagingMode/ScrollViewPagingMode.html

If you use that, each 'page' would have n buttons/views that when clicked would call a protocol/delegate call back for the consumer with the data to handle and it would evenly layout the UIView/buttons across that page view. Contact me if you want my sample.

You probably don't want to require iOS6 as a minimum requirement but if you do, you can do as H2CO3 suggested in the comment and us UICollectionview. Here's a tutorial: http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12

There's also some open source launchers that you can look into their code. Here's some (I'm sure there's more).

http://www.cocoacontrols.com/platforms/ios/controls/sespringboard

Code is at: https://github.com/sarperdag/SESpringBoard

Also: http://www.cocoacontrols.com/platforms/ios/controls/openspringboard

like image 199
bryanmac Avatar answered Dec 07 '25 06:12

bryanmac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!