swift - Change cell title in TableViewController in another ViewController -
i'm trying change title in tableviewcontroller viewcontroller. (see image)
the second viewcontroller 1 3 cells , third 1 one textfield (inputtext in code), button (changetext) , label (outputlabel). app remember put in text field when go table view , viewcontroller. happens is:
- change text, hit button , label changes.
- go tableviewcontroller , go viewcontroller in changed label
- label before...
how can make app 'remember' put in in text field , label like? code (viewcontroller.swift, linked 3rd controller file, haven't linked 2nd controller (yet?)):
import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var outputlabel: uilabel! @iboutlet weak var inputtext: uitextfield! @ibaction func changetext(_ sender: uibutton) { outputlabel.text = inputtext.text } override func viewdidload() { super.viewdidload() // additional setup after loading view. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. }
thanks in advance!
you can reference viewcontroller
in first controller (tableviewcontroller
), make public inputtext
@iboutlet public weak var inputtext: uitextfield!
and in viewdidappear
text
override func viewdidappear(_ animated: bool) { super.viewdidappear(animated) let text = viewcontrollervar.inputtext.text //your text }
Comments
Post a Comment