views:

80

answers:

3

I have a Nav controller that starts at a table view. Each row pushes to a detail UIView. I would like to have a "next" button on the Detail UIView that would pop the current view and open the one corresponding to the next row on the parent UITableView using the the same view controller without returning to the TableView. Ideally, it would use some slide or fliip animation.

Thoughts?

A: 

I figured this one out. Basically, I load the next view and push it on the nav stack and then remove the current view from the stack. It is a bit of a hack hard coding the object reference, but it works and the animation looks nice.

Here is the key code snippet:

Michael Bordelon
A: 

I figured this one out. Basically, I load the next view and push it on the nav stack and then remove the current view from the stack. It is a bit of a hack hard coding the object reference, but it works and the animation looks nice.

Here is the key code snippet:

NSMutableArray *allControllers = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
        NSLog(@"Controller Count:%d", [allControllers count]);
        NSInteger backCount = 2;
        [allControllers removeObjectAtIndex:[allControllers count] - backCount];
        [self.navigationController setViewControllers:allControllers animated:NO];
        [allControllers release];



        [self.navigationController popViewControllerAnimated:YES];
Michael Bordelon
A: 

The way I do this:

// Push the blog view, but don't add to the stack by popping first.
[self.navigationController popViewControllerAnimated: NO];
[listViewController.navigationController pushViewController: detailViewController animated:YES];

The listViewController in the code is the parent view with the table view. The detailViewController is one that you need to create first, containing the details of the next element in the list.

If you want to go back, that is up in the table, you need slightly different code:

// Fake a pop animation by pushing the controller, then pushing a dummy and popping back.
DummyController* dummy = [DummyController alloc];
[self.navigationController popViewControllerAnimated: NO];
[lListViewController.navigationController pushViewController: detailViewController animated:NO];
[detailViewController.navigationController pushViewController:dummy animated:NO];
[dummy.navigationController popViewControllerAnimated:YES];

This nicely animates the page transitions.

robject