欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS 實(shí)現(xiàn)模糊搜索的功能

 更新時(shí)間:2016年12月08日 16:36:54   作者:一片云一片雨  
模糊搜索的實(shí)現(xiàn)思路是當(dāng)搜索框開(kāi)始編輯時(shí)對(duì)搜索框中的文本與后臺(tái)給的資源相對(duì)比,包含搜索文本的展示在tableview中

模糊搜索的實(shí)現(xiàn)思路是當(dāng)搜索框開(kāi)始編輯時(shí)對(duì)搜索框中的文本與后臺(tái)給的資源相對(duì)比,包含搜索文本的展示在tableview中.

關(guān)鍵部分代碼如下:

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText 
{ 
self.result = nil; 
for (int i = 0; i < self.nameArray.count; i++) { 
NSString *string = self.nameArray[i]; 
if (string.length >= searchText.length) { 
if([self.nameArray[i] rangeOfString:searchText].location !=NSNotFound) 
{ 
[self.result addObject:self.nameArray[i]]; 
} 
} 
} 
[self.tableView reloadData]; 
} 

以上所述是小編給大家介紹的iOS 實(shí)現(xiàn)模糊搜索的功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論