UITableView中的实时搜索 [英] Real Time Search in UITableView

查看:125
本文介绍了UITableView中的实时搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个 UISearchBar 来查找 UITableView 中的元素。一切似乎工作正常,现在我正处于我需要实际搜索 textField 中按下的每个键的部分,并按下每个按钮缩小搜索范围。

I have implemented a UISearchBar for finding an element in UITableView. Everything seems to work fine, and now I am at the part where I need to actually perform real-time search for every key pressed in the textField, and narrow down the search with every button press.

所以在开始编码之前,我想知道是否有任何内置的库函数可以帮助我进行实时搜索? (字符串比较)或其他什么?

So before I start coding, I wanted to know if there is any inbuilt library function that could help me with live search ? (string comparison) or anything ?

你的答案可以节省我一些时间。

Your answer could save me some time.

谢谢。

推荐答案

事实上,实际上有一个内置函数可以帮助实时搜索。 P !.

It so happens that there is in fact an inbuilt function that helps with RealTime Search. Phew !

NSRange match = [userNameString rangeOfString:searchText options:NSCaseInsensitiveSearch];
// match.location will provide the exact location of a match of searchText with a String
// match.length will provide the length of match 

这篇关于UITableView中的实时搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆