Domanda

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?

È stato utile?

Soluzione

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];
     }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top