iPhone 是否有相当于 NSTokenField 控件?

发布于 2024-08-02 21:49:46 字数 248 浏览 2 评论 0原文

在我的应用程序中,我希望用户在 UITextField (或等效项)中输入名称,然后当他们按回车键时,它将将该单词放入通常与标签关联的蓝色气泡中。然后光标移动到末尾,他们可以在其中添加更多“标签”。

在“收件人”、“抄送”和“收件人”中添加联系人时可以看到这一点。邮件应用程序中的密件抄送字段以及在消息应用程序中选择联系人时也是如此。

这是怎么做到的?它是 UIKit 中提供的还是其他地方提供的?

非常感谢,

迈克尔

In my app I want the user to type names into a UITextField (or equivalent) and then when they press return, it will put that word(s) in a blue bubble that's usually associated with tags. The cursor then moves to the end where they can add more "tags".

This can be seen when adding contacts in the To, CC & BCC fields in the Mail app, and also when selecting contacts in the Messages app.

How is this done? Is it something that's provided in the UIKit or available somewhere else?

Many thanks,

Michael

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

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

发布评论

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

评论(5

我是男神闪亮亮 2024-08-09 21:49:46

Venmo 刚刚开源了他们的代币字段。

https://github.com/venmo/VENTokenField.git

Venmo just open sourced their token field.

https://github.com/venmo/VENTokenField.git

以往的大感动 2024-08-09 21:49:46

编辑:

桌面版 Cocoa 中的等效控件是 NSTokenField< /code>,但似乎没有 Cocoa Touch 的等效项。

edited:

The equivalent control in desktop Cocoa is an NSTokenField, but there doesn't seem to be an equivalent for Cocoa Touch.

许一世地老天荒 2024-08-09 21:49:46

自 iOS 13 起,存在 UISearchTextField

https://developer.apple.com/documentation/uikit/uisearchtextfield

可以看到该组件在照片应用程序中运行。
这应该适合许多用例。通过删除 leftView 您还可以摆脱搜索图标。

但请注意:您不能在不同位置混合文本和标记。

来自文档:

标记始终连续出现在搜索字段中任何文本之前。

Since iOS 13 there exists UISearchTextField.

https://developer.apple.com/documentation/uikit/uisearchtextfield

You can see that component in action in the Photos App.
That should fit for many use cases. By removing the leftView you can also get rid of the search icon.

But be aware: You can‘t mix text and tokens at various positions.

From the docs:

Tokens always occur contiguously before any text in the search field.

℉服软 2024-08-09 21:49:46

在这里添加这个作为参考:

随意查看 TaggerKit (我制作的一个库),它或多或少少了OP正在谈论的内容。您基本上只需添加一个视图和几个属性即可向您的应用程序添加标签功能。

Adding this here for reference:

Feel free to check out TaggerKit (a library I made), it's more or less what OP was talking about. You can basically add tags functionality to your app by just adding a view and a couple of properties.

我认为您无法使用 SDK 中的任何内置功能来做到这一点,从未见过这样的功能。然而,你可以做的是自己实现它,有一些自定义的蓝色按钮,上面有一些文本,当用户点击返回时,你可以有一些代码来获取文本并返回你需要的按钮,应该不会太糟糕实施

I dont think you can do it with any built in functionality in the SDK, never seen such a feature. What you could do however is implement it yourself, have some custom blue button with some text over it, and when the user hits return you can have some code that takes the text and returns you the button that you need, shouldnt be too bad to implement

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