Reputation: 3417
I wanted to have a tab bar controller, then a table view controller with a corresponding detail view. I am new to this, so I tried combining Apple's SimpleDrillDown: http://developer.apple.com/library/ios/#samplecode/SimpleDrillDown/Introduction/Intro.html
...with Ray Wenderlich's tutorial on Storyboards: http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
Ray's shows you how to set up the tabs and get the first table view, but then doesn't show you how to get a detail view, so then I tried to learn how to get the detail view from Apple's SimpleDrillDown (which doesn't have the tab bar controller).
My program runs with no errors, but when you click on a row in the table view (FactSheetsViewController), it stays blue (selected) and never segues to my FactSheetsDetailViewController. If I put a breakpoint in my table view class at this method:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"DisplaySelectedFactSheet"]) {
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
FactSheetsDetailViewController *detailViewController = [segue destinationViewController];
detailViewController.factSheet = [dataController objectInListAtIndex:selectedRowIndex.row];
}
}
The breakpoint is never reached when I run the program and click on a cell.
I'm not sure what other code to post, because I'm not sure what I did wrong. I'm wondering if I initialized things incorrectly in my AppDelegate?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
FactSheetsViewController *factSheetsViewController = [[navigationController viewControllers] objectAtIndex:0];
DataController *controller = [[DataController alloc] init];
factSheetsViewController.dataController = controller;
self.dataController = controller;
return YES;
}
Or, if I'm not setting things up correctly in the storyboard somehow. I set the identifier to my segue from FactSheetsViewController to my FactSheetsDetailView to "DisplaySelectedFactSheet" in the attributes inspector.
I'm happy to post more details if it would help - please just let me know! Thank you.
Upvotes: 1
Views: 1066
Reputation: 70185
In Xcode, you need to create a segue between the table cell (prototype) and the FactSheetsDetailViewController
. Then, also in Xcode, edit the segue name to be DisplaySelectedFactSheet
.
Upvotes: 1