views:

274

answers:

1

I've got a nice table populated with data, with custom-designed cell layouts. Currently, tapping a cell will push in a new view (for more information, say), which works fine.

What I'd like to do, though, is have the new view push into the cell's bounds, not fill up the whole screen. Can't seem to wrap my brain around how to accomplish this -- any pointers you could offer?

Thanks! :)

Update: Here's some of the code, in case that helps the helpers:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

FlippedViewController *flippedViewController = [[FlippedViewController alloc] initWithNibName:@"FlippedView" bundle:nil];

// What goes in here? Where do contentView and originalView come from?

[originalView removeFromSuperview];
[contentView addSubview:flippedViewController.view];

[flippedViewController release];
}
A: 

You can add a hook in tableView:didDeselectRowAtIndexPath: (a method of UITableViewDelegate) which uses a pointer to the particular cell's contentView, and performs the changes on that UIView just as it would any other.

For example, if you wanted to simply replace originalView (assuming that's what's in the cell now) with newView, you could do something like this:

// Use your own data structure and indexPath to retrieve contentView.
[originalView removeFromSuperview];
[contentView addSubview:newView];

That would update the view without an animation.

About the animation -- here are two related previous questions:

Tyler
Okay, we're getting somewhere, thanks. Bear with my noviceness here for a sec...Right now, inside `tableView:didSelectRowAtIndexPath:`, I've got this:`[self.navigationController pushViewController:self.editView animated:YES];`Where would I find out what my analogs for your `originalView`, `contentView`, and `newView` are?
Triz
Every UITableViewCell has its own UIView called contentView. You'd have to store a map from table row# (and maybe section#) to the contentView's so you can look that up. Depending on your setup, you might only have one visible UIView as a child of contentView - that would be your originalView. And newView is whatever you want to show up in its place - based on your comment, it sounds like you want self.editView to be the replacement, assuming that's a UIView object.
Tyler
I've been working on this all night, and am still a little stymied, alas. I can't seem to find out how to reference the `contentView` of the current cell. I've got the new view all set up and ready to add as a subview, but... I'll paste some code into the question above, see if that helps? Thanks again!
Triz