简体   繁体   English

如何使用UISearchBar搜索网络?

[英]How do I use UISearchBar to search the web?

I want to use the UISearchBar and used its text which further can be put into a url and that url will search the web. 我想使用UISearchBar并使用其文本,该文本可以进一步放入url中,并且该url将在网上搜索。 I am unable to dismiss the keyboard. 我无法关闭键盘。 I have tried using the first responder thng but that doesn't seems to work. 我尝试使用第一响应者thng,但这似乎不起作用。 I am new to iPhone development and fairly new to programming world so please bear with me. 我对iPhone开发并不陌生,对编程世界也不陌生,所以请耐心等待。 any help would be appritiated. 任何帮助将不胜感激。

Add a search bar delegate to yourclass.h as following: 将搜索栏委托添加到yourclass.h ,如下所示:

@interface yourclass : yourviewcontroller < UISearchBarDelegate >

Then, implement this function of the delegate into yourclass.m : 然后,将委托的此功能实现到yourclass.m

(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
   [searchBar resignFirstResponder];
   //your code
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM