I have a UITabBarController which contains 4 tabs. On each tab there should be an icon within the navigationbar which allows the user to open my settings view. I solved this by creating a parent class for those 4 tabs and added an icon within the viewDidLoad method which calls a method that does the push. This soluation worked as expected so far.
But :-)! Now I would like to have this settings view open only one time. The solution I have at the moment allows the user to open the settings view on all 4 tabs simultaniously. I don’t want that – Is there an approach to have the settings open only one time?
Here’s my code (which is placed in the parent file)
-(void)viewDidLoad
{
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(showSettings)];
}
- (void)showSettings
{
[self.navigationController pushViewController:[[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil] animated:YES];
}
Any advice?
Assuming all your tabs are
UINavigationControllers, in-showSettingswalk the other tabs and pop the navigation view controller if it’s aSettingsViewController.