searchDisplayController在iOS 8中已弃用 [英] searchDisplayController deprecated in iOS 8

查看:752
本文介绍了searchDisplayController在iOS 8中已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更正以下内容,以免出现警告?
我缺少什么?

How do you correct the following so no warnings appear? What am I missing?

searchResultsController 更正为 searchController 它给我一个错误找不到对象

When correcting the searchResultsController to searchController it gives me an error "object not found"

if (tableView == self.searchDisplayController.searchResultsTableView) {
        cell.textLabel.text = [searchResults objectAtIndex:indexPath.row];
    } else {
        cell.textLabel.text = [_content objectAtIndex:indexPath.row];
    }

    return cell;
}

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
  shouldReloadTableForSearchString:(NSString *)searchString
{
    [self filterContentForSearchText:searchString
                               scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
                       objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
    return YES;
}


推荐答案


UISearchController 类替换了 UISearchDisplayController
类,用于管理与搜索相关的接口的显示。

The UISearchController class replaces the UISearchDisplayController class for managing the display of search-related interfaces.

来源: https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html

所以,正如rmaddy所说,如果你想摆脱已弃用的警告,请停止使用已弃用的类。改为使用 UISearchController

So, as rmaddy said, if you want to get rid of the deprecated warnings, stop using the deprecated classes. Use UISearchController instead:

https://developer.apple.com/library/ios/documentation/UIKit/Reference/ UISearchController / index.html#// apple_ref / occ / cl / UISearchController

这篇关于searchDisplayController在iOS 8中已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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