在 iPhone 应用中打开网页时,如果用 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; 这种方法的话,会退出当前软件,启动 Safari。下面是用 UIWebView 在当前程序中打开网页的代码
NSString *urlAddress = @"http://localhost";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];