ios7 - 搜索栏同时显示 "e"和 "é"的结果

标签 ios7 dictionary uisearchbar

我有一个 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];
                  }


}

}

非常感谢

最佳答案

根据 Larme 的提示,答案非常简单!对于以后遇到此问题的所有情况,请使用以下代码:

NSRange nameRange = [author.name  rangeOfString:text options:NSAnchoredSearch | NSDiacriticInsensitiveSearch];

NSRange descriptionRange = [author.genre rangeOfString:text options:NSAnchoredSearch | NSDiacriticInsensitiveSearch];

关于ios7 - 搜索栏同时显示 "e"和 "é"的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22956903/

相关文章:

ios - 如何在iOS中使用动态按钮上的标签?

Python 参数作为字典

Swift 字典默认值

swift - 当我在 Swift 上按下搜索栏时如何关闭键盘?

ios - 如何在 UINavigationBar 中隐藏 UISearchController

javascript - 在用户关闭弹出窗口之前,如何检测 iOS7 选择菜单上的更改事件?

iOS 7状态栏透明

ios - 无效的图像路径 - 未找到图像

ios - 将 "Get"请求数据分配给文本字段

ios - 关闭搜索栏后,UINavigationBar 后退按钮始终变为蓝色