Cursor does not appear on initial click in UITextField

47 views Asked by At

I have a custom cell with 3 UITextFields. They are all set up the same way just with different names. 2/3 work perfectly, the cursor shows on initial click and the keyboard pops up. The tricky one (weightTextField) does not work as expected. The cursor does not show on initial click, but the keyboard does pop up, and the cursor appears as soon as the user types the first character.

Storyboard Setup for Custom Cell

   var currentWorkoutSet: WorkoutSet!
   
   @IBOutlet weak var setNumLabel: UILabel!
   @IBOutlet weak var repsTextField: UITextField!
   @IBOutlet weak var weightTextField: UITextField!
   @IBOutlet weak var rpeTextField: UITextField!
   
   static let identifier = "WorkoutViewCell"
   
   static func nib() -> UINib {
      return UINib(nibName: "WorkoutViewCell", bundle: nil)
   }
   
   
   override func awakeFromNib() {
      super.awakeFromNib()
      
      // Initialization code
      if let item = currentWorkoutSet {
         item.reps = 0
         item.weight = 0.0
         item.rpe = 0.0
      }
      initTextFields()
   }
   
   func initTextFields() {
      repsTextField.keyboardType = UIKeyboardType.decimalPad
      weightTextField.keyboardType = UIKeyboardType.decimalPad
      rpeTextField.keyboardType = UIKeyboardType.decimalPad
   }

I have tried resetting the connection between the text fields, checking the setup between the 3, checking the settings in the storyboard for the text fields, and reading the docs for textFields and cursor.

I would like a couple more things to try or a way to manually show the cursor when the user clicks on the textField.

1

There are 1 answers

0
Coleman On

Just need to extend the textField. The width was the same as the others, which looks fine when there are numbers entered. However, the placeholder text was longer so the cursor would not appear.