I would like to keep subviews (UITextFields in this case) still active (editable in usual way i.e. tap on the textField and a keyboard appears) while the parent view which is a UITableViewCell's userInteractionEnabled is set to false.
Explaining further - 1. There is a UITableViewCell initialized from a xib.
- Inside this cell, I have three UITextFields and a UIButton.
- On some condition, I need to disable the cell interaction (to avoid the didSelectRowAtIndexPath) - this part, I do not have any problem.
- After step 3, all the subViews inside the cell are getting disabled as well.
- But I need to enter some text inside the textFields and tap the button with some action to it.
What I did so far: 1. Used userInteractionEnabled and set it to false for the cell -
myPersonalInfoExpandedCell.userInteractionEnabled = false
2. Two textFields firstNameText and lastNameText, I enabled userInteraction and set it firstNameText to becomeFirstResponder
(myPersonalInfoExpandedCell as! PersonalInfoExpandedCell).firstNameText.userInteractionEnabled = true
(myPersonalInfoExpandedCell as! PersonalInfoExpandedCell).lastNameText.userInteractionEnabled = true
(myPersonalInfoExpandedCell as! PersonalInfoExpandedCell).firstNameText.becomeFirstResponder()
Problem is, for the textFields, the userInteractionEnabled
is not working which I suspect because of userInteractionEnabled
is false for the TableViewCell.
The becomeFirstResponder()
is working for firstNameText
but I need interaction to all the UI Elements inside the cell.
How can we do that? Please could someone help?