Popover with Splitview inside - ios

I want to create programmatically a UIPopoverController with a UISplitViewController inside. The Problem is that the Master-View is overlaying the Detail-View. It seems that the Master-View is popped over the Detail-View. That means i can see both, Master & Detail but the Split is not correct.
Have a look here:
http://i.stack.imgur.com/En70W.png
Any idea how to solve that ?
Thx
.m File
UISplitViewController *customSplitVC = [[UISplitViewController alloc] init];
ListViewController *listViewController = [[ListViewController alloc] init];
listViewController.title = #"Master";
listViewController.content = self.myContent;
UINavigationController *masterNC = [[UINavigationController alloc] initWithRootViewController:listViewController];
masterNC.view.frame = CGRectMake(0, 0, 500, masterNC.view.frame.size.height);
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.title = #"Detail";
UINavigationController *detaillNC = [[UINavigationController alloc] initWithRootViewController:detailViewController];
detaillNC.view.frame = CGRectMake(600, 0, 500, detaillNC.view.frame.size.height);
[customSplitVC setViewControllers:#[masterNC, detaillNC]];
self.popover = [[UIPopoverController alloc] initWithContentViewController:customSplitVC];
self.popover.delegate = self;
self.popover.popoverContentSize = CGSizeMake(1000, 425);
[self.popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:(UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp) animated:YES];

UISPlitViewController has to be set as the root view controller, so you cannot put it inside a UIPopoverController.
You can try using a 3rd party split view controller though:
https://github.com/Raizlabs/RZSplitViewController

Related

How to create a splitviewcontroller fron a view?

I am new in Xcode. I have viewcontroller with a navigation tabbar with items. I need that one on this menu item calls a splitview with master/detail. Is possible create a splitview in a view and not necessary in appdelegate? In appdelegate I have create one splitview, but if an option on menu.
Is possible to put this code in a the view that i clic the barbutton? The code used is:
detallContactesAccions = [[[CrmContactesAccionesDetallVC alloc] init] initWithNibName:#"CrmContactesAccionesDetallVC" bundle:nil];
masterContactesAccions = [[CrmContactesAccionesMasterTVC alloc] initWithStyle:UITableViewStylePlain];
masterContactesAccions.detailViewController = detallContactesAccions;
masterContactesAccions.navigationItem.title = NSLocalizedString(#"Acciones",#"");
UINavigationController *navMaster = [[[UINavigationController alloc] initWithRootViewController:masterContactesAccions] autorelease];
UINavigationController *navDetail = [[[UINavigationController alloc] initWithRootViewController:detallContactesAccions] autorelease];
splitViewController = [[UISplitViewController alloc] init];
//splitViewController.tabBarItem = controller.tabBarItem;
[splitViewController setValue:[NSNumber numberWithFloat:300.0] forKey:#"_masterColumnWidth"]; //Dóna més amplada a l'split view
splitViewController.viewControllers = [NSArray arrayWithObjects:navMaster, navDetail, nil];
splitViewController.delegate = detallContactesAccions;

Present a View Controller modally when selected in Tab Bar Controller

I have this pretty standard Tab Bar Controller setup:
UIViewController *homeViewController = [[PLOTHomeViewController alloc] init];
UIViewController *upcomingViewController = [[PLOTUpcomingViewController alloc] init];
UIViewController *checkInViewController = [[PLOTCheckInViewController alloc] init];
UIViewController *watchlistViewController = [[PLOTWatchlistViewController alloc] init];
UIViewController *profileViewController = [[PLOTProfileViewController alloc] init];
PLOTNavigationController *homeNavVC = [[PLOTNavigationController alloc] initWithRootViewController:homeViewController];
PLOTNavigationController *upcomingNavVC = [[PLOTNavigationController alloc] initWithRootViewController:upcomingViewController];
PLOTNavigationController *checkInNavVC = [[PLOTNavigationController alloc] initWithRootViewController:checkInViewController];
PLOTNavigationController *watchlistNavVC = [[PLOTNavigationController alloc] initWithRootViewController:watchlistViewController];
PLOTNavigationController *profileNavVC = [[PLOTNavigationController alloc] initWithRootViewController:profileViewController];
self.tabBarController = [[PLOTTabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:homeNavVC, upcomingNavVC, checkInNavVC, watchlistNavVC, profileNavVC, nil];
However, I'm trying to work out how, when the user selects the middle tab (checkInViewController), I can present that View Controller modally (fullscreen)? I'd maybe imagine something in the viewDidAppear method in that VC, but I'm not sure if you can present yourself modally, if you're a VC? What's the best approach for this?
You can use
[self presentViewController:checkInViewController animated:YES completion:nil];
Then hide the tab and navigation bars in the destination view controller's viewWillAppear:
-(void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.tabBarController.tabBar setHidden:YES];
}

iOS 7.1: Why does my custom UITableViewController inside UINavigationController inside WEPopoverController not appear?

I have a view controller hierarchy.
WEPopoverViewController
UINavigationController
CustomUITableViewController
The UITableView of the CustomUITableViewController does not appear, the PopOver is shown, but empty. viewDidLoad of CustomUITableViewController is called, but viewWillAppear:animated and viewDidAppear:animated are not called.
Here is the code for setting up the hierarchy:
CustomUITableViewController* browser = [[CustomUITableViewController alloc] init];
browser.delegate = self;
browser.preferredContentSize = CGSizeMake(650, 750);
browser.title = NSLocalizedString(#"FileImportBrowserTitle", nil);
UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:browser];
nc.preferredContentSize = CGSizeMake(700, 900);
nc.delegate = self;
WEPopoverController *poc = [[WEPopoverController alloc] initWithContentViewController:nc];
browser.parentPopover = poc;
[poc presentPopoverFromBarButtonItem:self.browseButton permittedArrowDirections: UIPopoverArrowDirectionUp animated:YES];
Any hints are welcome.

Navigation Bar isn't not showing up

I'm using MGSplitViewController for my iPad application.
I have added a viewController to it's detailViewController this way:
my2ndVC *vc = [[my2ndVC alloc] init];
splitViewController.detailViewController = vc;
It works perfect, now when I'm adding a navigationBar to my2ndVC
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 448, 44)];
[self.view addSubview:navBar];
The bar isn't showing up.
I know I can add my2ndVC like this:
my2ndVC *vc = [[my2ndVC alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
splitViewController.detailViewController = navController;
But then I also have a condition in one of my view controller:
if ([splitViewController.detailViewController isKindOfClass:[my2ndVC class]])
What would be the suggested workaround?
Cant you change your condition as follows:
if ([splitViewController.detailViewController.topViewController isKindOfClass:[my2ndVC class]])
To Make it simpler :
UINavigationController *aNavigationController = (UINavigationController *)splitViewController.detailViewController;
if ([aNavigationController.topViewController isKindOfClass:[my2ndVC class]]) {
// TRUE...
}

TabBarController within the RootViewController of a SplitViewController

I'd like to develop an iPad app which would be composed of a SplitViewController. I'd like to add a TabBarController in the RootViewController.
I'm at the very beginning of the development. So I've started to simply create a new project, add a SplitViewController via Interface Builder and test the app, no problem of course. Then I've tried to add the TabBarController to the RootView, no problem either via the Interface Builder. The problem I have there is that I can't make the app rotate with the device. I assume that I have to change something in the code but I don't know what :-(
I've noticed that the method shouldAutorotateToInterfaceOrientation is never called when the device rotates.
I'm sorry to ask this question but I'm very new in developping iPad/iPhone apps.
Best regards
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:annualViewController];
[navigationController1.navigationBar addSubview:imageView1];
[list addObject:navigationController1];
[imageView1 release];
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:rootViewController];
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"navigation bar.png"]];
imageView2.frame = CGRectMake(0, 0, 320, 44);
[navigationController2.navigationBar addSubview:imageView2];
[list addObject:navigationController2];
[imageView2 release];
tabBarController.viewControllers=list;
detailViewController = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:nil];
rootViewController.detailViewController = detailViewController;
annualViewController.detailViewController=detailViewController;
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:tabBarController, detailViewController, nil];
splitViewController.delegate = detailViewController;
// Add the split view controller's view to the window and display.
[window addSubview:splitViewController.view];
[window makeKeyAndVisible];

Resources