Post

Replies

Boosts

Views

Activity

Reply to TextField Action After Done
I am trying to allow the textField I have to accept an Int that moves a slider, I can get it to work by commenting out my function that only allows values from 10 to 90. func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {     // Make sure the user entered a number   let num = Double(textField.text!)   if num! < 10 {       textField.text = "10%"   } else if num! > 90 {       textField.text = "90%"   } else if num! >= 10 || num! <= 90 {       textField.text = String(Int(num!)) + "%"   }   //print(num!)   return true }
Nov ’20
Reply to TextField Action After Done
Thats the thing I'm struggling with. I modified the function so it can be better understood. widthPer is the textField I have selected to change my slider value when a value is entered but it does not work and the textField returns nil. func textFieldShouldReturn(_ textField: UITextField) -> Bool {   textField.resignFirstResponder()   let text = textField.text   let textNum = Int(text!)   if widthPer.text == text {     slider.value = Float(textNum!)   } return true }
Nov ’20
Reply to TextField Action After Done
Okay I see what you mean but I have an issue implementing it for two textfields. It says my text value is nil and it does not move the slider. func textFieldShouldReturn(_ textField: UITextField) -> Bool {   textField.resignFirstResponder()   let text = textField.text   let textNum = Int(text!)   /*when you enter a value it will affect, the slider and squareOne width value will change and squareTwo width will change */   if widthPer.text == text {     squareOneWidth.constant = CGFloat(textNum!) * 2     slider.value = Float(textNum!)     calPercentage()     calPercentageTwo()     /*when you enter a value it will affect, the sliderHeight and squareOne height will change and squareTwo height will change */   } else if heightPer.text == text {     calPercentage()     calPercentageTwo()   }   print("\(text)")   return true }
Nov ’20