0

I have a view1 with all controls created programmatically. Once i click on a textbook i will go to view2 which has a tableview with search bar. User can select the tableviewcell value and the value should be displayed in the View1 in the textbook control.

I want to use this view2 as user control whenever a dropdown value to be selected. I am doing this right ?

The problem here is i am able to programmatically push the view controller to view2 . But after selecting the value in View2 i am not able to segue back to View1 with the value selected.

Is this scenario possible at all? If not what would be the solution.

NOTE: I have 2 views view1 to view2. View1 acts like a data input form. View2 acts like a dropdown.

On click of button in View1 i am doing this

func ButtonPressed()
{    print("Button Pressed!!")

    // This will create the new instance of the view controller.

let vc = UIStoryboard(name:"Main",     bundle:nil).instantiateViewController(withIdentifier: "Storage") as! testClass
self.navigationController?.pushViewController(vc, animated:true)


}

Once view 2 is loaded then i am selecting a value in view2 and i want to segue back to the same instance of View1 so that i don't loose the values.

How can i achieve this??

Thanks in advance.

DEV
  • 861
  • 1
  • 9
  • 26
  • 1
    You need to use delegate or completion block to get back the value in first view. Post some of your code so that i can help you. – Janmenjaya Aug 30 '16 at 01:20
  • Use unwind segue http://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-do-you-use-them – Shades Aug 30 '16 at 01:28
  • show code where you setting values? – Bista Aug 30 '16 at 05:12
  • In the view1 i have added @IBAction func prepareForUnwind(segue: UIStoryboardSegue) { print("unwind successful") } – DEV Aug 30 '16 at 14:18
  • In the view1 i have added @IBAction func prepareForUnwind(segue: UIStoryboardSegue) { print("unwind successful") } In the view2 the code is func backButtonTapped() { print("Button Tapped") self.performSegue(withIdentifier: "prepareForUnwind", sender: self) } The problem here is i am not creating the segue from view1 to view2 in the story board and i want to create it programmatically only but i cannot segue without an identifier. – DEV Aug 30 '16 at 14:23
  • I have edited my post explaining clearly what i want. Please suggest accordingly. Thank you. – DEV Aug 30 '16 at 14:31

0 Answers0