我的UISplitViewController
仅显示UIViewController
见图:
这是我的appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
splitViewController.delegate = splitViewController.viewControllers.lastObject;
return YES;
}
在这里你可以看到我的故事板:
我该如何解决这个问题?
更新
DetailViewContainerController.m
-(void)mineSygedomme:(int)viewId {
UIViewController *viewController;
switch (viewId) {
case 0:
viewController = self.vaccinationer;
[self.navigationController setNavigationBarHidden:NO animated:NO];
break;
case 1:
viewController = self.skadestuen;
[self.navigationController setNavigationBarHidden:NO animated:NO];
break;
case 2:
viewController = self.leagen;
[self.navigationController setNavigationBarHidden:NO animated:NO];
break;
}
[self showChildViewController:viewController];
}
-(void)showChildViewController:(UIViewController*)content {
if(topController != content) {
content.view.frame = [self.view frame];
[self.view addSubview:content.view];
[content didMoveToParentViewController:self];
topController = content;
}
}
LeftMenuviewcontroller.m
- (void)awakeFromNib
{
[self.splitViewController setDelegate:self];
self.clearsSelectionOnViewWillAppear = NO;
self.preferredContentSize = CGSizeMake(300.0, 600.0);
[super awakeFromNib];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.detailViewContainerController = (DetailViewContainerController *)[self.splitViewController.viewControllers lastObject];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewContainerController *test2 = [[self.splitViewController.viewControllers.lastObject childViewControllers] objectAtIndex:0];
// test2.detailViewContainerController = self;
test2.forNavn = [arrayA objectAtIndex:indexPath.row];
NSLog(@"test3 = %@",test2.forNavn);
if ([[[self.fetchedResultsController objectAtIndexPath:indexPath] valueForKey:@"gender"]isEqualToString:@"Pige"]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main-iPad" bundle:nil];
DetailViewContainerController *controller = [storyboard instantiateViewControllerWithIdentifier:@"MenuPige"];
controller.forNavn = [arrayA objectAtIndex:indexPath.row];
NSLog(@"pige = %@", controller.forNavn);
[self.navigationController pushViewController:controller animated:YES];
}
if ([[[self.fetchedResultsController objectAtIndexPath:indexPath] valueForKey:@"gender"]isEqualToString:@"Dreng"]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main-iPad" bundle:nil];
DetailViewContainerController *controller = [storyboard instantiateViewControllerWithIdentifier:@"MenuDreng"];
controller.forNavn = [arrayA objectAtIndex:indexPath.row];
NSLog(@"dreng = %@", controller.forNavn);
[self.navigationController pushViewController:controller animated:YES];
}
}