ボタンがある条件を達成するまで無効化されているプログラムを作りたいのですがうまくいきません.
例ではボタン1を5回押すとボタン2が押せるようになるようにしているつもりです.
初心者なため変数の位置など全然違うかもしれません.
import UIKit
class ViewController: UIViewController {
var point = 1
@IBAction func button1(sender: AnyObject) { point = point+1 } @IBAction func button2(sender: UIButton) { if point<5{ sender.enabled = false }else{ sender.enabled = true } }
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. }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。