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++)") } }
you cannot change ui element in first interface controller when not active.
here 1 possible way:
- send
self
of first interface controller second 1 (usingpushcontrollerwithname("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
popcontroller
method. - when first interface controller activated, read out property , update button accordingly (in method
willactivate
).
Comments
Post a Comment