0
我意識到這個問題之前已經被提過很多次了,但我不能完全得到解決方案,即使只是複製和粘貼它們,並且懷疑大多數快速文檔跨越自swift發佈以來的三個版本。將字段輸入作爲變量存儲爲swift 3
我試圖做一些簡單的事情,像存儲一個字段輸入的變量,沒有太多的運氣。
import UIKit
class ViewController: UIViewController {
@IBOutlet var userNumber: UILabel!
@IBOutlet var userField: UITextField!
@IBAction func userButton(_ sender: UIButton) {
let userInput = userField.text
//some action
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
您是否將IBOutlet和IBAction連接到故事板? –