iPhone 用 JSON 结果填充 UITableView(使用在 UISearchBar 中输入的搜索)

标签 iphone objective-c ios json uitableview

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

谢谢!

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

最佳答案

在您的类中实现 UISearchBarDelegate 方法。然后您可以在此委托(delegate)方法中访问 Web 服务

- (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];

关于iPhone 用 JSON 结果填充 UITableView(使用在 UISearchBar 中输入的搜索),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7550222/

相关文章:

iphone - 将 MPMediaItem(播客)标记为已收听

iphone - UIDatePickerModeCountDownTimer 模式下的 UIDatePicker : how to get/set the hours and minutes via code?

objective-c - 为什么这个 UIView 在某些情况下没有被添加为 subview ,但在其他情况下却可以?

当用户在“系统设置”->“显示和亮度”上启用 "Bold Text"时,iOS 应用程序会在启动屏幕上卡住

android - Qt/QML SwipeDelegate 在移动设备(Android、iOS)上无法正常工作

ios - swift 3 : Preload SecondViewController's WKWebView ahead of click

iphone - 如何从此结构中获取数据,JSONKit

javascript - 减少react-native-paper TextInput 的高度和垂直填充

objective-c - 替换已弃用的 NSNibLoading 方法(loadNibFile :, loadNibNamed :, 等)?

objective-c - iOS 将 UIView 平行于 X-Z 平面对齐