i'm playing around with the great library ZUUIRevealController. However, I can't program it so the user are able to tap a cell in the rearcontroller. The rearcontroller should then go away and display a new viewcontroller in the front view.
I've setup my project like this:
VGViewController *frontViewController;
RevealController *rearViewController;
frontViewController = [[VGViewController alloc] initWithNibName:@"VGViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
rearViewController = [[RevealController alloc] initWithNibName:@"RevealController" bundle:nil];
ZUUIRevealController *revealController = [[ZUUIRevealController alloc] initWithFrontViewController:self.navigationController rearViewController:rearViewController];
[frontViewController release];
[rearViewController release];
self.window.rootViewController = revealController;
[revealController release];
[self.window makeKeyAndVisible];
return YES;
I hope someone can help me! :D
glad you found a liking in the library.
Your project seems to be setup correctly if I'm not missing anything, although logically I'm not able to follow how the rearViewController <=> RevealController but that's okay I guess.
To answer your question: In order to display a different frontViewController by, say tapping on a cell in the rearViewController you need to trigger this piece of code in the appropriate method (say: tableView:didSelelctRowAtIndexPath:)
// RearViewController.m file in some method:
// - Let's grab a reference to the revealController first:
ZUUIRevealController *revealController = [self.parentViewController isKindOfClass:[ZUUIRevealController class]] ? (ZUUIRevealController *)self.parentViewController : nil;
// Check if we're not attempting to swap the current FrontViewController for exactly the same controller over again...
if (![revealController.frontViewController isKindOfClass:[NewFrontViewController class]])
{
NewFrontViewController *newFrontViewController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
newFrontViewController = [[NewFrontViewController alloc] initWithNibName:@"NewFrontViewController_iPhone" bundle:nil];
}
else
{
newFrontViewController = [[NewFrontViewController alloc] initWithNibName:@"NewFrontViewController_iPad" bundle:nil];
}
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:newFrontViewController];
[newFrontViewController release];
[revealController setFrontViewController:navigationController animated:NO];
[navigationController release];
}
What this piece of code does is, it grabs a reference to the rearViewControllers parent (which should be the revealController), and assigns a new frontViewController instance to it by calling [revealController setFrontViewController:navigationController animated:NO];
Hope this solves your problem :-)