2013-08-19 3 views
0

웹 피드 의 데이터로 UISearchBar 필드를 자동 채우는 방법은 어떻게됩니까? JSON 피드를 통해 도시 목록에 액세스 할 수 있으며 UISearchBar 필드에 표시하려는 경우 사용자가 "San ..."을 입력하면 샌디에고 자동 완성이 자동 완성됩니다. "샌프란시스코 .."가 입력되고 자동 표시가 "샌프란시스코"등인 경우 변경됩니다.JSON 웹 피드의 데이터로 UISearch 필드를 자동으로 채우는 방법은 무엇입니까?

나는 도시 이름을 다루고 있으며 사용자가 도시를 잘못 철자하고 결과를 얻지 못하도록하고 싶지 않습니다. 그것의. 어떤 도움

감사

+2

내가 비슷한 질문을했다 : http://stackoverflow.com/questions/12948710/textfield-autocompletion-with-json-response – Bhavin

답변

0
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ 

if ([searchText length] != 0) 
{ 

    [searchArray removeAllObjects]; 

    for (get every city name from original array) 
    { 
     NSRange titleResultsRange = [cityname rangeOfString:searchText options:NSCaseInsensitiveSearch]; 

     if (titleResultsRange.length > 0) 

      <add that object into searchArray] 

      //NSLog(@"items is %@",_items); 
    } 

} 

[self.tableViewItems reloadData]; 

} 
관련 문제