如何使用搜索结果快速更新textField.text

时间:2018-11-03 01:11:16

标签: swift uitextfield

我有一个从GradientView继承的SearchBar类。我根据输入的文本实现了自动单词搜索。我正在将搜索结果提取到tableView中,并将其显示在searchBar下。当我在搜索结果中选择一个单元格时,我希望将“ didSelectRowAtIndexPath”值附加到searchBar中已经存在的文本上。

1 个答案:

答案 0 :(得分:0)

您应该为其他人发布相关代码,以更好地为您提供帮助。

根据您提供的信息,该代码应足以满足您的要求。

func didSelectRowAtIndexPath {
    let updatedText = (self.searchBar.text ?? "") + self.yourArrayName[indexPath.item]
    self.searchBar.text = updatedText
}