Friday 15 August 2014

ios - Set Navigation View Controller title from prior View Controller depending on button pressed -


New enough for iOS development.

I have an embedded view controller in a navigation controller.

In this view controller I have two buttons (buttonon and two buttons), when another view controller (exercise exercise controller) is pressed.

Depending on the problem I am facing, the title of the exercise exercise controller is changing, which is pressed.

So if the button is pressed then the exercise exercise controller's title is set to one.

If the button two is pressed then the title of exercise exercise controller two has to be set.

Both view controllers have different classes.

..

View the controller - View the controller. M - Exitview Controller - H - Exercise Controller

Thanks for any help in advance.

you

prepareForSegue: from: your view controller In. It will be called and will provide a trigger button. If you set a tag on the button or checks what the headline should be, then decide it. After that you can set the title on the SIIC destinationViewController .

In your XIB, you can set the tags of the buttons for '1' and '2'. Or, you can do this in your viewDidLoad :

  self.buttonOne.tag = 1; Self.buttonTwo.tag = 2;   

Then in prepareForSegue you can:

  - Prepare (zero) ForSegue: (UIStoryboardSegue *) to sender sender : (Id sender {if ([segue.identifier is EqualToString: @ "showRecipeDetail"]) {NSInteger tag = [(UIButton * Sender tag]; CertViewController * destViewController = segue.destinationViewController; DestViewController.title = (tag == 1? @ "One": @ "two"); }}    

No comments:

Post a Comment