如何在iPhone中实现谷歌搜索应用程序(How to implement google search application in iphone)

编程入门 行业动态 更新时间:2024-10-25 00:26:42
如何在iPhone中实现谷歌搜索应用程序(How to implement google search application in iphone)

我是iPhone开发的新手。 我正在制作一个应用程序,我需要实现Google搜索应用程序并显示以下结果...

如果有任何教程来实现此应用程序,任何人都可以请帮助。 有没有教程? 我认为下面给出的代码是正确的,如果是这样,那么应该添加什么才能使它工作?

谢谢

NSLog(@"%@",searchBarGoogle.text); NSString *string1 = [[NSString alloc] initWithFormat:@"%@",searchBarGoogle.text]; NSString *string = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",string1]; NSURL *url = [NSURL URLWithString:string]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request];

I am new to iPhone development. I am making an application where I need to implement Google Search application and display the results below...

Can anyone please help if there is any tutorial to implement this application. Is there any tutorial? I think the code given below is right, if so then what else should be added to make it work?

Thank you

NSLog(@"%@",searchBarGoogle.text); NSString *string1 = [[NSString alloc] initWithFormat:@"%@",searchBarGoogle.text]; NSString *string = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",string1]; NSURL *url = [NSURL URLWithString:string]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request];

最满意答案

在你的.h文件中

#import <UIKit/UIKit.h> @interface eddwedViewController : UIViewController { IBOutlet UITextField *searchtextField; } -(IBAction)search; @end

在.m文件中

- (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } -(IBAction)search { NSString *searchString=searchtextField.text; NSString *urlAddress = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",searchString]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlAddress]]; }

在您的视图中,controller.xib将文本字段连接委托与文件所有者和出口及其名称。 创建一个按钮并将其与搜索方法连接起来。

如果它适合您,请告诉我。

in your .h file

#import <UIKit/UIKit.h> @interface eddwedViewController : UIViewController { IBOutlet UITextField *searchtextField; } -(IBAction)search; @end

In your .m file

- (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } -(IBAction)search { NSString *searchString=searchtextField.text; NSString *urlAddress = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",searchString]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlAddress]]; }

In your view controller.xib make a textfield connect delegate with file owners and outlet with its name. Make a button and connect it action with search method.

Let me know if it is working for you.

更多推荐

本文发布于:2023-07-16 10:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   如何在   iPhone   implement   iphone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!