Question

I have my main window with a Navigation Bar and one BarButton in the top right corner. I have a saved value, and depending on if it is TRUE or FALSE, I want to push to a different controller. Now pushing to one is just Ctrl+Drag in IB, but what about if I want to choose beween views to push? Any suggestions?

Was it helpful?

Solution

Just implement a simple IBAction that you connect with your ~UIBarButton

-(IBAction)barButtonPressed {
     if (yourBoolean) {
          TrueViewController *trueViewController = [[TrueViewController alloc] init];
          [self.navigationController pushViewController:trueViewController animated:YES];
     } else {
          FalseViewController *falseViewController = [[FalseViewController alloc] init];
          [self.navigationController pushViewController:falseViewController animated:YES];
     }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top