在新的safari上的mac他們有一個欄可以區分谷歌和url.Thats我想要做的。我想知道我做錯了什麼。它只想谷歌不搜索網址。提前致謝。如何使網址和谷歌欄成爲一個UIWebView
-(IBAction)SearchAll:(id)sender
{
if (googlebar) {
NSString *query = [googlebar.text stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.google.co./search?q=%@", query]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}
else{
NSString *query = [googlebar.text stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.%@", query]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}
}
你在哪裏得到錯誤? – Coder404
以及你是如何定義searchBar的? (在if語句的開頭) – Coder404
IBOutlet UITextField * searchBar; @ Coder404 – user1592698