그래서 웹이나 Google에서 검색 할 수있는 텍스트 필드를 만들었습니다. 문제는 Google에서 한 단어 이상을 검색 할 수 없다는 것입니다. Stackoverflow를 검색 할 수는 있지만 예를 들어 Stackoverflow 질문을 검색 할 수 없습니다. 코드는 다음과 같습니다.Google에서 검색하기
{
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