ビューに Google 検索バーが必要です。テキストフィールドと検索ボタンを作成し、それを検索方法にリンクしようとしましたが、機能しません。私はiOS開発分野に不慣れなので、親切に助けてください。ありがとうございました。
こちらが「ViewController.m」
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor= [UIColor cyanColor];
searchtext = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 200, 40)];
searchtext.delegate = self;
searchtext.borderStyle = UITextBorderStyleRoundedRect;
[self.view addSubview:searchtext];
search = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[search setTitle:@"Search" forState:UIControlStateNormal];
[search setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
search.frame = CGRectMake(210, 0, 100, 30);
[self.view addSubview:search];
[search addTarget:self action:@selector(gotogooglesearch) forControlEvents:UIControlEventTouchUpInside];
-(void)gotogooglesearch{
NSMutableString *googleUrl = [[NSMutableString alloc] initWithString:@"http//www.google.com/search?q="];
NSString * searchString = [searchtext text];
[googleUrl appendString:searchString];
NSURL *url = [NSURL URLWithString:googleUrl];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end