1
所以我做了一個文本字段,在那裏我可以搜索網頁或谷歌。問題是,我無法在google上搜索多個單詞:例如,我可以搜索Stackoverflow,但無法搜索Stackoverflow問題。這裏的代碼:在谷歌搜索
{
if ([textField.text hasPrefix:@"http"]){
url=[NSURL URLWithString:[textField text]];
request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}else{
stringOne = @"http://www.google.com/search?q=";
NSString *stringTwo = TextField.text;
NSString *googleSearchString =[stringOne stringByAppendingString:stringTwo];
NSURL *google = [NSURL URLWithString:googleSearchString ];
request = [NSURLRequest requestWithURL:google ];
[webView loadRequest:request];
}
}
謝謝你的幫助!
它的工作原理!非常感謝!我正在爲這個問題尋找解決方案,我花了太多時間搜索它!再次感謝你! – Adri 2012-02-20 19:14:42