如何在填写TextField时出现建议?

发布于 2025-01-10 03:14:44 字数 179 浏览 0 评论 0原文

我是IOS开发新手。我正在尝试添加简单的文本字段来输入职业。我想在用户输入时向用户展示一些匹配的建议(来自我已经拥有的一组职业)。

这是一个非常常见的用例。有这样做的惯用方法吗?在 Android 中,标准视图库中有一个 AutoCompleteTextView,它在初始化期间接收一系列建议。我在 IOS 中找不到类似的东西。

I am new to IOS development. I am trying to add simple TextField for entering Occupation. I would like to show the user some matching suggestions as they user type (from a set of occupations that I already have).

This is a very common usecase. Is there a idiomatic ways of doing this? In Android there is an AutoCompleteTextView in the standard view library which takes in an array of suggestions during initalization. I could not find anything similar in IOS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦中楼上月下 2025-01-17 03:14:44

您可以使用一些可用于自动完成文本字段的第三方库

从我的角度来看,最好、最简单的方法是使用 UITextField 并在底部添加 UITableview。所以这个概念是,当您在文本字段中键入任何字符时,您需要从表视图中过滤一些数据并重新加载表视图

检查下面的链接,您可以从这里获得合适的答案...

让自动完成功能在 swift 中工作

You can use some 3rd party libraries available for Auto complete text field
but
the best and easy approach from my perspective is to use UITextField and at bottom add UITableview. So the concept is when you type any character in textfield you need to filter some data from tableview and reload tableview

Check the below link you can get the suitable answer from here...

Getting autocomplete to work in swift

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文