beretis
beretis

Reputation: 909

Ipad design with multiple tableviews

I'm developing chat application for ipad and I'm wondering about native messages app.

so thats two tableviews in one screen but how to handle two tableviews in one controller properly? Also that navigation bar, is it single navigation bar and some kind of separator? Any help will be appreciated. Thank you

Upvotes: 0

Views: 425

Answers (3)

Duncan C
Duncan C

Reputation: 131418

Your link is broken, so it's hard to tell for sure what you a trying to do.

As others have said, you can use a split view controller for hierarchical content if that's what you are trying to do. I don't think the iOS messages app uses

You can also manage the table views yourself. Don't use a UITableViewController; set up a regular UIViewController yourself. All the table view delegate and data source methods pass in the table view as the first parameter, so you can write your methods to branch based on the table view that is calling you.

Another option would be to use the parent/child view controller scheme and have your main view controller contain 2 different child UITableViewController objects, and set up a protocol for the child table view controllers to talk to the parent.

I have an app on github that is an example of using this technique. It's quite easy in iOS 6 or later, since you can use embed segues. Here is the link.

My app is based on static table views however. It would need to be modified to deal with separate data sources for each table view.

Upvotes: 0

RyanG
RyanG

Reputation: 4503

There is a control called UISplitViewController

You could also put 2 separate UITableViews on your UIViewController, then handle it in the delegates/datasource methods, ie:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if(tableView == _leftTableView)
        {
             static NSString *CellIdentifier = @"Cell";
             UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

             if (cell == nil) {
                 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
             }

             //fill cell data here

             return cell;
        }
        else if(tableView == _rightTableView)
        {
             static NSString *CellIdentifier = @"Cell";
             UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

             if (cell == nil) {
                 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
             }    

             //fill cell data here

             return cell;
         }
         return nil;
    }

Upvotes: 1

Hackmodford
Hackmodford

Reputation: 3970

A UISplitViewController is what Apple used.

Upvotes: 1

Related Questions