8

I'm looking to build a document "selector" screen, similar to Pages and Numbers on the iPad/iPhone: Document Selector Screen

I come from a WPF background and have some iOS experience. That being said, I'm looking for a good approach to building something like the tile-based interface Apple uses for opening documents in Pages.

I'm not concerned with the Folder animation.

What is the best way to approach building just the tile interface? I'd imagine I'd build some sort of view that sits within a UIScrollView - but it's the nature of that subview that I'm a little confused about. Does iOS have any wrap-panel or grid-like controls I could load a set of tiles (i.e., documents) into?

What do you guys think?

themechanix1
  • 205
  • 2
  • 8

2 Answers2

5

I don't know of any third-party classes to handle this for you, but there might be some out there.

The basic structure will be a UIScrollView containing a set of views, each representing one cell on the grid. You set the scroll view's contentSize based on the total number of tiles. Then you create tile views on demand, and place them inside the scroll view.

The scroll view's delegate object will be responsible for monitoring the scroll position, putting down tile views as they become visible, and (optionally) removing tile views that move out of view. This is basically how UITableView works: there are only about six or so instances of UITableViewCell at any given time, they are recycled as you scroll up and down the view. (Imagine a train where somebody at the back end is pulling out the rails and passing them forward to somebody in the front, putting them down in front of the train. As far as the train knows, the rails go on for miles.)

If you wind up having to place all the views yourself, take some time to learn the CGRect family of methods, including CGRectDivide. They will be useful in laying out the views and also in computing what's visible and what's not.

benzado
  • 82,288
  • 22
  • 110
  • 138
0

There are a few third party classes/libraries you can get to produce this functionality, AQGridView comes to mind. But there are no default easy classes for this.

If I was to develop this type of implementation, I would subclass UITableViewController. Expand it to have columns. Then subclass a UITableViewCell to display the image. That way all the container code and everything would already be there, and all you have to do is customize it to f it your needs.

ColdLogic
  • 7,206
  • 1
  • 28
  • 46
  • 3
    Oh goodness no, don't force this into a UITableView. You would be fighting against all sorts of default behavior like row selection. A plain scroll view is much better. – benzado Jul 28 '11 at 19:13
  • Lol, you have some to fight, but you gain a lot as well. You can create your own custom plain scroll view all you want. Whats the easiest way to do it is a matter of opinion. I also dont see how row selection would be something to fight, the uitableview knows what row you select... – ColdLogic Jul 28 '11 at 19:18