【问题标题】:iPhone Filling UITableView with JSON results (using search entered in UISearchBar)iPhone 用 JSON 结果填充 UITableView(使用在 UISearchBar 中输入的搜索)
【发布时间】:2011-09-26 02:50:48
【问题描述】:

有没有人有一个教程的链接,该教程使用 UISearchBar 作为搜索条目,并使用 UITableView 来显示以 JSON 格式返回的结果?

谢谢!

请不要向 RTFM 提出任何建议 - 我找不到任何关于使用 UISearchBar 进行远程搜索的信息。

【问题讨论】:

    标签: iphone objective-c ios json uitableview


    【解决方案1】:

    在您的类中实现 UISearchBarDelegate 方法。然后你就可以在这个委托方法中访问网络服务了

    - (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
    {
    //Hit the webservice from here using searchBar.text
    
    }
    

    或者如果您需要动态搜索,您可以使用以下方法。

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

    从服务器获取数据后,更新 tableView 的数据源并调用 (您可以使用 SBJSON 解析器来解析您的 JSON 响应)

    [self.tableView reloadData];
    

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多