Reputation: 75
Okay so I am creating an app for iPhone using a navigation controller and basically what I need to let my addviewcontroller
know what the user selected on the addsettingsviewcontroller
. So when the user hits the save button it opens the addviewcontroller and when that is opened it needs to check what value was selected on the previous view. I can get it to do all that for me but the only problem is that when the save button is pressed and the addviewcontroller
loads the navigation bar is no longer there so the user cannot hit the back button and the view's title isn't showing.
Here is a picture of my storyboard.
Upvotes: 0
Views: 81
Reputation: 1818
If you are using storyboard, let it handles your push or modal as you specified in it. Don't disrupt it by using code that upset the flow.
Declare this in AddViewController.h
@property (nonatomic, strong) NSNumber *status;
Then, in your AddSettingsViewController.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"Add"])
{
AddViewController *addViewController = segue.destinationViewController;
addViewController.status = Selected_Status;
}
}
Selected_Status can be something like:
[NSNumber numberWithInteger:self.levelSegmentedControl.selectedSegmentIndex];
Upvotes: 0
Reputation: 2162
Try this one
Addviewcontroller *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"addView"];
controller.status = easy; // select as enum of easy, medium, hard
[self.navigationController pushViewController:controller animated:YES];
Hope this helps you !
Upvotes: 1