This is the first time I've tried writing an iOS app in... 8 months... and the first time I've tried using a SplitViewController ever. Anyways, here's what I want:
A settings menu that goes through a two-pane hierarchy, with minimal coding involved. I figure Storyboards will be great for that.
I have a MasterViewController, which is a UITableView subclass. Here's the significant code for it:
It all works up until the bolded lines. navController ends up being null. After examining a little more, I found self.splitViewController was also null. Any suggestions as to why that is? I've checked my storyboard and everything is of the proper classes... (that is the Master View Controller is an AESSettingsMasterViewController, and everything else is of standard UIKit classes.)
I've attached a screenshot of my storyboard.
Edit: Also, everything is embedded in a tab bar controller (which is the root / initial view controller for my entire app,) but that wouldn't be causing the issues, would it?
A settings menu that goes through a two-pane hierarchy, with minimal coding involved. I figure Storyboards will be great for that.
I have a MasterViewController, which is a UITableView subclass. Here's the significant code for it:
Code:
// In the header I make NSArray* categories; an ivar.
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
categories = [NSArray arrayWithObjects:@"General", @"Personalize", @"Data Collection", @"Graph", @"About", nil];
}
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [categories count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Category"];
if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Category"];
cell.textLabel.text = [categories objectAtIndex:indexPath.row];
return cell;
}
- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Settings";
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIViewController* newViewController = [self.storyboard instantiateViewControllerWithIdentifier:[categories objectAtIndex:indexPath.row]];
[b]UINavigationController* navController = [self.splitViewController.viewControllers lastObject];
[navController setViewControllers:[NSArray arrayWithObject:newViewController] animated:NO];[/b]
}
It all works up until the bolded lines. navController ends up being null. After examining a little more, I found self.splitViewController was also null. Any suggestions as to why that is? I've checked my storyboard and everything is of the proper classes... (that is the Master View Controller is an AESSettingsMasterViewController, and everything else is of standard UIKit classes.)
I've attached a screenshot of my storyboard.
Edit: Also, everything is embedded in a tab bar controller (which is the root / initial view controller for my entire app,) but that wouldn't be causing the issues, would it?
Attachments
Last edited: