-4
私は単純なこんにちは世界のアプリを作った。ボタンをタップするたびに、ボタンを別のテキスト名に変更します。私はラベルに "こんにちは"と言いたいと思います。もう一度ボタンをタップすると、 "さようなら"と言いたいと思います。私は毎回この変更をボタンをタップします。私は数日間試してみましたが、私はまだそれを取得しないでください。 輸入のUIKitこのようなHello Worldアプリの問題
class ViewController: UIViewController {
@IBOutlet weak var labelText: UILabel!
@IBAction func buttonTapped(_ sender: Any) {
if labelText.text == "hello" {
} else {
labelText.text = "goodbye"
}
}
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.
}
}