ios - 敲击时键盘打不开
问题描述
我在表格视图中有文本字段。每当点击文本字段时,就会出现另一行带有文本字段的行。但是点击文本字段时键盘没有打开。它正在创建一个文本字段,但键盘没有打开。这是我的代码:
@IBOutlet weak var contactPersonsTableView: UITableView!
var contactPersons = [String]()
var index = 0
override func viewDidLoad() {
super.viewDidLoad()
self.hideKeyboardWhenTappedAround()
// Do any additional setup after loading the view.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return contactPersons.count + 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "contactPersonCell", for: indexPath) as! ContactPersonTableViewCell
cell.contactPerson.delegate = self
cell.contactPerson.tag = indexPath.row
return cell
}
func textFieldDidBeginEditing(_ textField: UITextField) {
index = textField.tag
textField.becomeFirstResponder()
if(textField.text!.isEmpty)
{
contactPersons.insert("", at: index)
contactPersonsTableView.reloadData()
}
}
解决方案
推荐阅读
- ios - 调用原始方法时,Xamarin 方法在设备上调用失败
- javascript - Javascript 安全地检查嵌套子级
- php - 尝试显示 Wordpress 缩略图时出现 500 错误
- php - 如何将输入信息从 androidstodio 发送到 Localdatabase
- javascript - 在 Azure 上找不到 Nodemon
- java - 使用 Enterprise Security API Java 对阿拉伯文本进行编码
- hyperledger-composer - 找不到任何要为事务执行的函数
- java - 如何在 Java 9 Set.of 中保持秩序
- ios - 尝试获取视频文件的大小 (kb) 时出错
- spring-boot - spring-boot 1.5 ConfigurationProperties,属性中的数字在使用烤肉串案例时没有绑定