Post

Replies

Boosts

Views

Activity

Reply to Disable TextFields Then Enable Them
This is the code I have its similar to the example in my textFieldShouldReturn function. I don't have the textFields empty as default. The thing is I don't wanna disable it when it's not empty because your right thats bad user experience. With my textFields there is an option to clear and I don't want them editing the other textField when they don't fill in the one they cleared.  if widthPer == textField {     heightPer.isUserInteractionEnabled = false     widthPer.isUserInteractionEnabled = true   } else {     heightPer.isUserInteractionEnabled = true     widthPer.isUserInteractionEnabled = false   }
Dec ’20
Reply to Disable TextFields Then Enable Them
Your right I removed the force unwrappings and fixed the nil issue but even with that the issue still persists. What I need is code for when you click on a textField and it's empty that you can't click on another textField nearby (isUserInteractionEnabled = false) but vice versa with the other textField.
Dec ’20
Reply to Protocol Not Preparing Data
I found my mistake I was trying to transfer numText instead of originalNum. func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {       // Make sure the user entered a number     let num = Double(textField.text!)     originalNum = Int(textField.text!)!     if num! < 0 {         textField.text = "0"     } else if num! > 1000 {         textField.text = "1000"     } else if num! >= 0 || num! <= 1000 {         textField.text = String(Int(num!))     }     return true   } let numText = originalNum
Dec ’20
Reply to Disable TextFields Then Enable Them
I'm trying to have it like this using your own example, I made comments to explain it. if&#9;text1 == textField {     text2.isUserInteractionEnabled = false.&#9;//want text2 to not be used, text1 is only editable     text1.isUserInteractionEnabled = true   } else {     text2.isUserInteractionEnabled = true.&#9; //want text2 to be used, text2 is only editable     text1.isUserInteractionEnabled = false&#9;   }
Nov ’20
Reply to Can't set the slider to 0
I will give you what I do for one of them since the rest are the same, for ot I have one variable and four outlets, in a class called PoVC var otPerNum: Int = 0&#9;&#9; //number I use in the textField @IBOutlet weak var otStack: UIStackView!&#9; //I use this to get the maximum value and set the value for the slider in the beginning. otSlider.maximumValue = Float(otStack.frame.width) otSlider.value = Float(otStack.frame.width) * 0.9        @IBOutlet weak var otWidth: NSLayoutConstraint!&#9;&#9;&#9;//Use this to set what the measurement for how wide the shape is and control it using otWidth.constant.         @IBOutlet weak var otPer: UITextField!&#9;&#9; //textField I use         @IBOutlet weak var otSlider: UISlider!&#9;&#9;&#9;//This is the slider that controls the otWidth.constant and sends the number to the otPer.&#9;
Nov ’20