【发布时间】:2016-09-26 07:20:18
【问题描述】:
我想保持子视图(在这种情况下为 UITextFields)仍然处于活动状态(以通常的方式可编辑,即点击 textField 并出现键盘),而作为 UITableViewCell 的 userInteractionEnabled 的父视图设置为 false。
进一步解释 - 1.有一个从xib初始化的UITableViewCell。
- 在这个单元格内,我有三个 UITextField 和一个 UIButton。
- 在某些情况下,我需要禁用单元格交互(以避免 didSelectRowAtIndexPath) - 这部分我没有任何问题。
- 在第 3 步之后,单元格内的所有子视图也将被禁用。
- 但我需要在 textFields 中输入一些文本,然后点击按钮进行一些操作。
到目前为止我做了什么: 1. 使用 userInteractionEnabled 并将其设置为单元格的 false -
myPersonalInfoExpandedCell.userInteractionEnabled = false
2。两个 textFields firstNameText 和 lastNameText,我启用了 userInteraction 并将 firstNameText 设置为 becomeFirstResponder
(myPersonalInfoExpandedCell as! PersonalInfoExpandedCell).firstNameText.userInteractionEnabled = true
(myPersonalInfoExpandedCell as! PersonalInfoExpandedCell).lastNameText.userInteractionEnabled = true
(myPersonalInfoExpandedCell as! PersonalInfoExpandedCell).firstNameText.becomeFirstResponder()
问题是,对于 textFields,userInteractionEnabled 不起作用,我怀疑这是因为 userInteractionEnabled 对于 TableViewCell 是错误的。
becomeFirstResponder() 正在为 firstNameText 工作,但我需要与单元格内的所有 UI 元素进行交互。
我们怎样才能做到这一点?请问有人可以帮忙吗?
【问题讨论】:
标签: ios iphone swift cocoa-touch