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
- user tap on parent tablecell.
- execute didSelectRowAtIndexPath:(NSIndexPath *)indexPath. User select cell.
- 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.
精彩评论