Thank you @Claude31 for your continued help.
To answer your questions. "That means you have a button in the view in Interface Builder. Right ?", "Did you do this?"
Yes, I do have a button in the view in interface builder.
No, I did not drag to connect because the exercise is teaching me how to connect programmatically, not by ⌃ + click + drag.
However, your solution does work. If I ⌃ + click + drag from the empty circle to the button, it does connect. But repeating once again, I'm not trying to use the ⌃ + click + drag feature. I want to connect just by typing code (programmatically, I think it's called).
This is my code.
import UIKit
class ViewController: UIViewController {
@IBOutlet var toggle: UISwitch!
@IBOutlet var slider: UISlider!
@IBOutlet var button: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
/*Do any additional setup after loading the view.*/
button.addTarget(self, action: #selector(buttonTapped(_:)),
for: .touchUpInside)
}
@IBAction func buttonTapped(_ sender: Any) {
print("Button was tapped!")
if toggle.isOn {
print("The switch is on!")
} else {
print("The switch is off.")
}
print("The slider is set to \(slider.value).")
}
@IBAction func switchToggled(_ sender: UISwitch) {
if sender.isOn {
print("Switch is on!")
} else {
print("Switch is off!")
}
}
@IBAction func sliderValueChanged(_ sender: UISlider) {
print(sender.value)
}
@IBAction func keyboardReturnKeyTapped(_ sender: UITextField) {
if let text = sender.text {
print(text)
}
}
@IBAction func textChanged(_ sender: UITextField) {
if let text = sender.text {
print(text)
}
}
@IBAction func respondToTapGesture(_ sender: UITapGestureRecognizer) {
let location = sender.location(in: view)
print(location)
}
}
Post
Replies
Boosts
Views
Activity
I just realized that I had the developer documentation window open. For some reason, when this window is open, the "Hide Navigator" keyboard shortcut is no longer active. For all currently open Xcode windows. However, the command (⌘, 0) works only once to close the navigator in the developer documentation window then stops working until you close the window.
2020, Has this changed yet?
Ok, now I realize that the adjustable parameters are in a completely different view titled HexagonParameters. You create it later in the tutorial.