Is there an iPhone equivalent to the NSTokenField

2019-01-07 14:02发布

问题:

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

回答1:

Venmo just open sourced their token field.

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



回答2:

edited:

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



回答3:

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