swift - How to send data back to the previous interface controller? -


i update button title (grey button) in first interface controller pressing on blue button in second interface controller.

  • i able use counter in order update label, how send result first interface controller

  • should executed in second interface controller , result sent through push segue

  • how use pushcontrollerwithname("secondcontroller",context: ... )

should that:

var counter = 1  @ibaction func addone() {     greybuttonlabel.settitle("\(counter++)")    pushcontrollerwithname("secondcontroller", context : add) }   // second interface controller  override func awakewithcontext(context: anyobject?) {       super.awakewithcontext(context)            if let addone = context as? counter {          greybuttonlabel.settitle("\(counter++)")       } } 

enter image description here

you cannot change ui element in first interface controller when not active.

here 1 possible way:

  • send self of first interface controller second 1 (using pushcontrollerwithname("secondcontroller", context: ... )).
  • update property in first interface controller while second interface controller active.
  • you may programmatically go first interface controller calling second interface controller's popcontrollermethod.
  • when first interface controller activated, read out property , update button accordingly (in method willactivate).

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -