ios - 如何将谷歌即时搜索栏添加到 iOS 应用程序
<p><p>我想在我的 iOS 应用程序中添加一个谷歌即时搜索栏,就像 iOS Safari 中的一样,但我在任何地方都找不到它。你们能帮忙吗?
提前致谢。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我假设您正在使用 UISearchBar。 </p>
<p>您可以使用来自 </p> 的代码
<pre><code>- (void) searchBarSearchButtonClicked:(UISearchBar *)theSearchBar
</code></pre>
<p>在方法中</p>
<pre><code>- (void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
</code></pre>
<p>请记住,您不需要在 <strong>searchBar:textDidChange 中放弃FirstResponder。</strong></p>
<p>例如,在这个方法中可以是:</p>
<pre><code>NSError *error = nil;
// We use an NSPredicate combined with the fetchedResultsController to perform the search
if (self.mySearchBar.text !=nil)
{
if ()
{
NSPredicate *predicate = %@", self.mySearchBar.text];
;
}
}
else
{
NSPredicate *predicate =;
;
}
if (![ performFetch:&error])
{
// Handle error
NSLog(@"Unresolved error %@, %@", error, );
exit(-1);// Fail
}
// this array is just used to tell the table view how many rows to show
fetchedObjects = fetchedResultsController.fetchedObjects;
// dismiss the search keyboard
;
// reload the table view
;
}
</code></pre>
<p>随意 +1 这个答案,如果这对像我这样的人有帮助,他们来自谷歌搜索结果到这篇文章:) </p>
<p>刷51</p></p>
<p style="font-size: 20px;">关于ios - 如何将谷歌即时搜索栏添加到 iOS 应用程序,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/8302778/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/8302778/
</a>
</p>
页:
[1]