【发布时间】:2018-12-23 07:48:35
【问题描述】:
实现您在 gif 中看到的内容的正确方法是什么?这是一个带有文本字段的表格视图。当您点击一个文本字段时,一个文本视图会显示在它的键盘上。我有一个带有文本字段(valueTextField)的自定义表格视图单元的表格视图。在 cellforrow 中,我将文本字段的 inputview 设置为 UITextView。当我按下文本字段时,文本视图应该在顶部显示工具栏(带有“完成”按钮)但没有工具栏显示。当我点击 textview 时,仍然没有工具栏。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath) as! EditProfileTableViewCell
cell.isUserInteractionEnabled = true
cell.valueTextField.isUserInteractionEnabled = true
cell.valueTextField.delegate = self
toolBar = UIToolbar()
toolBar.sizeToFit()
let doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: #selector(editorDone))
toolBar.setItems([doneButton], animated: false)
editorTextView = UITextView(frame: CGRect(x:0, y:0, width:view.bounds.width, height:view.bounds.height))
cell.valueTextField.inputAccessoryView = toolBar
cell.valueTextField.inputView = editorTextView
return cell
}
【问题讨论】:
标签: swift uitextfield uitextview inputaccessoryview inputview