ios - UITextfield 在完成按钮单击 tableview 标题时删除

标签 ios swift xcode uitextfield swift4

我在 TableViewCell 上有一个文本字段。当我单击“完成”按钮时,文本字段会删除。当我向下滚动并向上滚动时,文本字段再次可见。

addSubview(search)

    search.leftViewMode = UITextField.ViewMode.always

    search.placeholder = "Поиск лекарств и товаров"
    search.backgroundColor = .white
    search.layer.cornerRadius = 10
    search.dropShadow(color: .black, opacity: 0.5, offSet: CGSize(width: 5, height: 5), radius: 5, scale: false)

最佳答案

   func textFieldShouldReturn(textField: UITextField) -> Bool {

        self.searchTextFieldShouldReturn = true
        textField.resignFirstResponder()

        return true
    }

关于ios - UITextfield 在完成按钮单击 tableview 标题时删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57353046/

相关文章:

ios - 在商业应用程序的 iOS 中使用 CorePlot 是否有任何限制?

ios - 状态栏方向值为 __C.UIInterfaceOrientation

ios - 独立的 iOS 应用程序和图标用于 Testflight 和生产构建

iphone - 在不适用于 iPhone 5.1 (XCode 4.3.2) 的 View 之间切换

ios - 为什么插入后出现删除的行而不是新行?

swift - 如何在一组结构实例中找到某些属性的匹配项?

xcode - 快速获取 UITableViewCell 内单元格的索引路径

ios - Ionic 3 - cocoapods 的 xcode 错误

ios - 在 UICollectionView Xcode 中添加 subview

ios - 我的 sqlite 查询(更新)在 iOS 中看起来不工作