作者:我要知道521无敌 | 来源:互联网 | 2023-05-18 04:34
IvehadthisproblemthatIhavebeenputtingoffsolving,butnowisthetime.我有这个问题,我一直推迟解决,但现在是
I've had this problem that I have been putting off solving, but now is the time.
我有这个问题,我一直推迟解决,但现在是时候了。
I have a basic dictionary program. It has a UISearchBar and a UITableView. It works the way that it should except when running on the device it causes Keyboard lag. (Simulator is fine, of course) I have two types of searching. As-you-type and On-return. I find that both take about the same amount of time to return results, but the As-you-type makes the keyboard lag.
我有一个基本的字典程序。它有一个UISearchBar和一个UITableView。它的工作方式除了在设备上运行时它会导致键盘滞后。 (模拟器很好,当然)我有两种类型的搜索。按你型和回程。我发现两者都需要大约相同的时间来返回结果,但是As-you-type会使键盘滞后。
I have UISearchBar textDidChange that takes the searchText and sends it to a search method that does all the sqlite lifting, puts the results in an Array. The reloads the table.
我有UISearchBar textDidChange,它接受searchText并将其发送到执行所有sqlite提升的搜索方法,将结果放入数组中。重新加载表格。
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
if((searchType == SEARCH_AS_YOU_TYPE) && ([searchText length] >= 2)){
NSString *myKeyword = [NSString stringWithFormat:@"%@", searchText];
[self search:myKeyword];
[myTableView reloadData];
}
}
I limit the results to 50. And I my SQL query uses the LIKE and OR, no way around that yet.
我将结果限制为50.而我的SQL查询使用LIKE和OR,还没有办法解决。
SELECT WORD_ID, DEFIN, PINYIN, SIMP, TRAD from WORDS where DEFIN LIKE "%to dog %" OR DEFIN LIKE "%dog" OR DEFIN LIKE "%dog%" ORDER BY DEFIN LIMIT 50
I've also tried moving the [myTableView reloadData] into the search method, in hopes that the keyboard would at least not lag. No Joy. And sadly I know that sqlite is basically checking every row, when it uses the like operator. But 3-4 seconds for 80rows seems kinda slow.
我也尝试将[myTableView reloadData]移动到搜索方法中,希望键盘至少不会滞后。没有喜悦。遗憾的是,我知道sqlite基本上是检查每一行,当它使用like运算符时。但是对于80人来说3-4秒似乎有点慢。
Any thoughts, ideas, comments or suggestions would be greatly appreciated!
任何想法,想法,意见或建议将不胜感激!
5 个解决方案