neotorama
neotorama

Reputation: 138

How to create custom uiviewtable?

I'm working on an app for my client. I'm stuck now.

I don't know how to explain. But i make a photoshop image of it.

https://i.sstatic.net/cV4mL.jpg

  1. user tap on parent tablecell.
  2. execute didSelectRowAtIndexPath:(NSIndexPath *)indexPath. User select cell.
  3. parent cell update.

Anyone know what is this called? Do you have tutorial for it?

Upvotes: 0

Views: 487

Answers (2)

cutsoy
cutsoy

Reputation: 10251

// FirstViewController (1st in your Photoshop-design)

...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SecondViewController *secondViewController = [[SecondViewController alloc] init];
    secondViewController.cell = [tableView cellForRowAtIndexPath:indexPath];
    [self.navigationController pushViewController:secondViewController animated:YES];
}

...

-------------------------

// SecondViewController.h

@interface SecondViewController : UITableViewController {
    UITableViewCell *cell;
}

@property (nonatomic, retain) UITableViewCell *cell;

-------------------------

// SecondViewController.m

...

@synthesize cell;

...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.cell.detailTextLabel.text = @"Something";
    [self.navigationController popViewControllerAnimated:YES];
}

...

Upvotes: 1

Eiko
Eiko

Reputation: 25632

Use UINavigationController with UITableViewController as its root controller and when diving deeper, instantiate a different UITableViewController for that and push it on the navigation stack. Popping is similar.

There are good examples for UINavigationController accessible from Apple's docs.

Upvotes: 0

Related Questions