views:

408

answers:

6

Normally, the UITableView is something like this:

[   cell    1   ]
[   cell    2   ]
[   cell    3   ]
[   cell    4   ]

But I want to make my own UITableView like this:

   |    |   |   |
   | c  | c | c |
   | e  | e | e |
   | l  | l | l |
   | l  | l | l |
   |    |   |   |
   | 1  | 2 | 3 |
   |    |   |   |

And I want the user swipe left and right to have the similar behavior like the original UITableView.... ...How can I do this? thank you.

+1  A: 

I don't think there is a available control which will enable you to do this. Your best bet is to roll your own.

In a nutshell you'll want to subclass UIScrollView, which will allow you to have more cells than you have room for on screen. It will also sort out all your swiping behaviour.

Into this scroll view you want to put a set of cells - I'd subclass UIView rather than trying to force UITableViewCell play nice with your Scroll View for these.

This is just a simple example of how to approach the problem. How many of the features of UITableView are you hoping to replicate?

pheelicks
A: 

Here is a tutorial on drawing a grid in a UITableView. http://www.iphonedevx.com/?p=153

Shaji
A: 

Other than subclassing UIScrollView, you could try applying a 90 degree rotation to an existing UITableView. I have no idea how that will affect scrolling, however, and you would have to specialize the cell views to "unrotate."

I think subclassing UIScrollView is a better option. Use the UITableView class as a guideline when it comes to the delegate, dataSource, and reusable cells.

MrHen
A: 

What you have is simply a standard table displayed in portrait orientation, but your are holding the phone in landscape mode. Rotate the contents of each cell 90 degrees and your there. And be sure to ignore any orientation change notifications.

Kenny
+2  A: 

There's a project here that might be of some use as well, http://github.com/TheVole/HorizontalTable

Tom Irving
great project! Thanks
thierryb
A: 

It isn't too terribly difficult to build up something similar to UITableView in code on your own. If you can find it, the expert-level Scroll Views session from WWDC09 had some awesome sample code.

Colin Barrett