NSTokenField 建议但未完成

发布于 2024-10-19 02:49:42 字数 222 浏览 1 评论 0原文

我觉得这一定是一个常见问题,我只是在努力弄清楚,但我找不到其他人问这个问题,所以...... 基本上,我有一个 NSTokenField,当用户开始输入时,我会发出 SOAP 请求并获取与他们输入的内容相似的名称。问题是我的建议不一定与他们输入的内容相符。例如,我匹配电子邮件和姓氏,但人的全名出现在建议数组中。由于字母不匹配,NSTokenField 会将已输入的内容更改为数组中的第一项。有没有办法关闭自动完成并只显示建议框?

I feel like this must be a common issue that I'm just struggling to figure out, but I couldn't find anyone else who asked the question so...
Basically I have an NSTokenField and when the user begins typing I make a SOAP request and get names that are similar to what they have entered. The issue is my suggestions don't necessarily match what they have typed. For example, I match email and last names, but a persons full name appears in the suggestion array. Since the letters don't match, NSTokenField changes what has already been typed to the first item in the array. Is there a way to turn off autocomplete and just have the suggestion box appear?

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

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

发布评论

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

评论(2

遗弃M 2024-10-26 02:49:42
    - (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
{
    *selectedIndex = -1;
    return NSArray;
}

事实证明,我错误地分配了 selectedIndex,但如果您将其设置为 -1,则不会选择任何内容。

    - (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
{
    *selectedIndex = -1;
    return NSArray;
}

It turns out that I was assigning selectedIndex incorrectly but if you just set it to -1 then nothing is selected.

可爱暴击 2024-10-26 02:49:42

很快答案是:

if selectedIndex != nil {
    selectedIndex.memory = -1
}

In swift the answer is:

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