开发者

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.

http://i.stack.imgur.com/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?


// 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];
}

...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜