Load Different View Controllers in the Master-Detail App template
Asked Answered
F

1

6

I am developing a master detail application using Xcode 4.3.3, now in the master view controller i have managed to load an additional view controller called "Fav Real"
When this view controller loads, it will contain different items taken from an sqlite database into a tableViewController.
My problem is here, i need when i click on any loaded row, to load a different viewController into the detailViewController, to load another view controller instead of the first one.
I am actually lost, i tried to do the following schema but i have no idea how to do my goal...Any help will be highly appreciated.enter image description here

As it shows, the items will load correctly in the FavReal tableView , but my goal is when i click at any row, the "Details" showing in the right will load instead of the DetailsViewController.
I tried this code in the FavReal.m but i always get : " Application tried to push a nil view controller on target .

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

 Details * vc4 = [self.storyboard instantiateViewControllerWithIdentifier:@"Details"];
 [self.navigationController pushViewController:vc4 animated:YES];

}

Thank you for your time, if any further details are needed please tell me

Flotsam answered 18/3, 2013 at 7:59 Comment(0)
F
0

In case anyone was having the same problem as i was, the only solution i found is not to load a different view controller and replace the original detailViewController, but the actual solution was to create a new storyboard and make it appear when the Favorites button is clicked, this way you'll have a nice stylish effect and keep your data presentation accurate. To do so use the following lines of code :

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"SecondStoryboard" bundle:nil];
UIViewController* initialHelpView = [storyboard instantiateInitialViewController];

initialHelpView.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:initialHelpView animated:YES];

You have the freedom to change the modal presentation as u prefer.
Best of luck

Flotsam answered 22/3, 2013 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.