Reputation: 7668
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?
Upvotes: 0
Views: 596
Reputation: 1579
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...
}
Upvotes: 1