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?

有帮助吗?

解决方案

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];
     }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top