Sorry Im new to Swift and I wanted to add a check mark functionality to my mock app. How can I add a check mark that would disable the selected row and then enable it when the check mark is deselected? Disable as in the row is visible but not tap-able.
Asked
Active
Viewed 267 times
1 Answers
0
You can do something like this. I used a button instead your checkbox.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var checkButton: UIButton!
@IBOutlet weak var textField: UITextField!
var enable = true;
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func touchButton(_ sender: Any) {
if enable {
checkButton.setTitle("Disable", for: .normal)
textField.isEnabled = false
enable = false
} else {
checkButton.setTitle("Enable", for: .normal)
textField.isEnabled = true
enable = true
}
}
}

Maxime
- 838
- 6
- 18