views:

93

answers:

1

Hello, all. I've been scouring the internet, and I haven't found a conclusive answer to this. If you look at the iPad App store (a number of other apps), the Categories tab has (what looks like) a 2-column table view.

One solution I've read using a web view (which I haven't yet explored in depth).

I've tried using subviews within a table cell. I can mimic a 2-column layout, but I can't get the touch events working properly. Before I try to continue down this path, I wanted to know if these are viable solutions or if there are other options.

If Apple is using this in the app store, I figure there must be some way to do this out of the box. Any help is appreciated!

A: 

It is really simple. Open you .xib file and create 2 (or as many as you want) UITableView. Add IBOutlets for each one of them by defining

IBOutlet UITableView *table1;
IBOutlet UITableView *table2;

Hook those up in the interface builder to each one of your tables, now in each table assign the delegate and dataSource to point to your View controller.

Now, you need to implement the basic UITableView functions like:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

Now inside of this methods, you can know which one is being asked for by checking the tableView value with your IBOutlet references. Like:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  if(tableView == table1){
    return 10;
  } else {
    return 5;
  }
}

You could get fancy and create different classes to handle those delegates in a different way or have a better pattern, but this is a good way to start =D

DFectuoso
you know, I remember seeing this, but back when I initially saw it, it seemed too complicated. But this seems to work perfectly. My only small nagging issue is that there isn't a border between the tables, but that's minor.anyway, if anyone is wondering, I just stuck 2 table views inside a scroll view, disabled scrolling for the tables, and adjusted the height to fit all rows. so far, working like a charm.thanks!