今この状態だと上に文章を書きボタンを押すとそのまま下に出てしまいます。
それを上の文章によってボタンを押した時に下に出てくる文章を変更させたいのです。
解決策をよろしくお願い申し上げます。
swift
1import UIKit 2 3class ViewController: UIViewController,UITextFieldDelegate { 4 5 6 @IBOutlet weak var yourlavel: UILabel! 7 @IBOutlet weak var textfield: UITextField! 8 9 override func viewDidLoad() { 10 super.viewDidLoad() 11 // Do any additional setup after loading the view, typically from a nib. 12 yourlavel.text = "" 13 } 14 var arigatou = "ありがとう" 15 var douitasimasite = "どういたしまして" 16 var konnitiha = "こんにちは" 17 var ohayou = "おはよう" 18 19 @IBAction func display(_ sender: Any) 20 { 21 self.yourlavel.text = self.textfield.text 22 23 if arigatou == douitasimasite { 24 print("どういたしまして") 25 } else if douitasimasite == ohayou { 26 print("こんにちは") 27 } 28 } 29 30 31 override func didReceiveMemoryWarning() { 32 super.didReceiveMemoryWarning() 33 // Dispose of any resources that can be recreated. 34 } 35}
回答1件
あなたの回答
tips
プレビュー