菜鸟教程小白 发表于 2022-12-12 09:30:45

ios - filterContentForSearchText :scope: method come from? 在哪里


                                            <p><p>最近,我注意到 <code>filterContentForSearchText:scope:</code> 出现在多个关于如何实现搜索栏的教程中。</p>

<p>但是,我查找了 <code>UISearchDisplayDelegate 和 UISearchBarDelegate</code> 的引用。我发现这个 <code>filterContentForSearchText:scope:</code> 既不是必需的也不是可选的方法。</p>

<p>我想知道 <code>filterContentForSearchText:scope:</code> 是否只是过滤搜索结果的常规方法名称?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>是的,这只是从 <code>UISearchDisplayDelegate</code> 方法调用的常用方法的约定</p>

<pre><code>- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString;
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption;
</code></pre>

<p>当前<a href="https://developer.apple.com/library/ios/samplecode/TableSearch/Introduction/Intro.html" rel="noreferrer noopener nofollow">&#34;Simple UISearchBar with State Restoration&#34;</a>
Apple 的示例项目<em>不</em>使用此约定:</p>

<pre><code>- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    NSString *scope;

    NSInteger selectedScopeButtonIndex = ;
    if (selectedScopeButtonIndex &gt; 0)
    {
      scope = [ objectAtIndex:(selectedScopeButtonIndex - 1)];
    }

    ;

    // Return YES to cause the search result table view to be reloaded.
    return YES;
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - filterContentForSearchText :scope: method come from? 在哪里,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/23199678/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/23199678/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - filterContentForSearchText :scope: method come from? 在哪里