开发者

Using UITextField and UIButton to launch a Google search in Safari

I am just finishing up the last part of my app, and I have done something similar before, but I took a pretty long break in coding and forgot.

What I'm trying to do is have the user enter a string in the UITextField and then have that added to a 开发者_如何学JAVAsearch string and opened in Safari.

Ideas appreciated!


Robb - Try this

NSString *searchString = @"iPhone"; // UItextField.text

NSString *finalString = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",searchString];

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:finalString]];

this will launch safari with search results of google.


Create the url and open it as a shared application. If you don't want to exit your app then you can probably open the url in a uiwebview.


You can make use of this

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urUrlString]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜