【发布时间】:2014-05-22 07:43:33
【问题描述】:
我有一个 UISearchBar 实现并正常工作。唯一的问题是,如果我在搜索栏中输入字母“e”,它只会正确显示以字母“e”开头的单词,而忽略所有以字母“é”开头/具有字母的单词。我确保所有关于将数据库加载到 NSMutableArray 的查询都是正确的 UTF-8 编码。但问题是,当用户按下“e”时,如何显示“e”和“é”的结果。几乎像所有法语词典一样工作!
这就是我在用户按下任何字母时过滤单词的方式:
for (Author* author in theauthorsLoadedFinal2)
{
NSRange nameRange = [author.name rangeOfString:text options:NSAnchoredSearch ];
NSRange descriptionRange = [author.genre rangeOfString:text options:NSAnchoredSearch];
if(nameRange.location != NSNotFound || descriptionRange.location != NSNotFound)
{
[filteredTableData addObject:author];
}
}
}
非常感谢
【问题讨论】:
-
寻找
NSDiacriticInsensitiveSearch。 -
@Larme 谢谢你的回复,但是我该如何实现它
-
@Larme 谢谢你的帮助!!!将其发布为答案,我会接受它:)
-
我刚刚给了你要查找的关键字。我实际上并没有给你代码或如何使用它(我从来没有自己使用它)。这只是您自己研究的提示。所以不要介意自己发布答案以及你如何使用它(代码)。
-
这应该是另一个问题,但要寻找 Diacritic 和 C#
标签: ios7 dictionary uisearchbar