Last active
August 29, 2015 14:22
-
-
Save carljparker/a5c20ae9cb247b08d2b9 to your computer and use it in GitHub Desktop.
Instantiate View Controller with Storyboard ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// The type of relationship you establish determines when a connected | |
// view controller is instantiated by iOS, as follows: | |
// | |
// - If the relationship is a segue, the destination view controller is | |
// instantiated when the segue is triggered. | |
// | |
// - If the relationship represents containment, the child view | |
// controller is instantiated when its parent is instantiated. | |
// | |
// - If the controller is not the destination or child of another | |
// controller, it is never instantiated automatically. You must | |
// instantiate it from the storyboard programmatically. | |
// | |
// https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/UsingViewControllersinYourApplication/UsingViewControllersinYourApplication.html | |
// [http://tinyurl.com/o98jbh6] | |
// | |
// Unless your VC has a XIB or you are creating it programmatically, as | |
// is the case with an alert controller, you should probably instantiate | |
// it with [sb instantiateViewControllerWithIdentifier:...] | |
// | |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSLog(@"%@", @"didSelectRowAtIndexPath"); | |
CheckinInfo * checkinInfo = (CheckinInfo *)self.checkinInfoList[indexPath.row]; | |
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; | |
ImageListTableViewController * imageListTableViewController = [sb instantiateViewControllerWithIdentifier:@"MyImageGallery"]; | |
imageListTableViewController.imageInfoList = checkinInfo.imageInfoList; | |
// ImageListTableViewController * imageListTableViewController = [[ImageListTableViewController alloc] initWithImageList:checkinInfo.imageInfoList]; | |
[[self navigationController] pushViewController:imageListTableViewController animated:YES]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment