Last active
August 29, 2015 14:03
-
-
Save eroth/7e00fb1455e96ba7dbc3 to your computer and use it in GitHub Desktop.
Pt 2: Obj-C find a parent UIViewController from the child VC (when the child's been pushed from a UINavigationController), then add a custom button to the child that will trigger a method on the parent
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
// This can all be done from the parent VC--AddSearchRegionsViewController is child | |
AddSearchRegionsViewController *addSearchRegionsVC = [[AddSearchRegionsViewController alloc] initWithNibName:@"BaseTableView" bundle:[NSBundle mainBundle]]; | |
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Test" style:UIBarButtonItemStyleBordered target:self action:@selector(didPressBackButtonOnAddSearchRegionsVC)]; | |
addSearchRegionsVC.navigationItem.backBarButtonItem = backButton; | |
[self.navigationController pushViewController:addSearchRegionsVC animated:YES]; | |
-(void)didPressBackButtonOnAddSearchRegionsVC { | |
for (AddSearchRegionsViewController *child in self.navigationController.viewControllers) | |
if ([child isKindOfClass:[AddSearchRegionsViewController class]]) { | |
self.selectedCellsFromRegions = child.selectedCells; | |
} | |
[self.navigationController popToViewController:self animated:YES]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment