我試圖從另一個ViewController更改TableViewController中的標題。 (見圖像)在另一個ViewController中更改TableViewController中的單元格標題
第二視圖控制器是一個與所述3個小區,第三個是(inputText的在碼)一用一文本框,按鈕(changeText)和一個標籤(outputLabel) 。我希望這個應用程序記住當我回到表視圖然後回到ViewController時我在文本字段中放置的內容。現在發生的是:
- 我改變文本,點擊按鈕,標籤改變。
- 我回到TableViewController,然後我進入的ViewController,我只是在用改變標籤
- 標籤是它以前...
我怎樣才能使應用程序「記住'我在文本字段中添加了什麼以及標籤是什麼樣的?我的代碼(ViewController.swift,我掛了3控制器添加到該文件中,都沒有掛第二控制器到任何東西(還)?):
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()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
提前感謝!
選中此http://stackoverflow.com/a/33549729/7250862 –