如何在iPhone中实现谷歌搜索应用程序

Abh*_*ash 4 iphone search objective-c ios

我是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];
Run Code Online (Sandbox Code Playgroud)

Gyp*_*psa 5

在你的.h文件中

#import <UIKit/UIKit.h>

@interface eddwedViewController : UIViewController {
    IBOutlet UITextField *searchtextField;

}
-(IBAction)search;

@end
Run Code Online (Sandbox Code Playgroud)

在.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]];
}
Run Code Online (Sandbox Code Playgroud)

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

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