試試這個。 使用此代碼在電流控制器
WebViewController *objWebViewController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
objWebViewController.m_strHtml=[NSString stringWithString:@"www.google.com"];//m_strHtml is a NSString variable in WebViewController class
[self.navigationController pushViewController:objWebViewController animated:YES];
[objContentWebViewController release];
使用此在WebViewController
NSURL *url = [[NSURL alloc] initWithString:m_strHtml];
NSURLRequest * req = [[NSURLRequest alloc] initWithURL:url];
[url release];
[Webview loadRequest:req];
[req release];
否則你可以加載一個網頁視圖和Web視圖內的HTML中打開的鏈接裏面
作爲默認。使用下面的代碼。
m_strHtml=[[NSString alloc]initWithFormat:@"<html><body>%@</body></html>",m_strHtmlContent];//m_strHtmlContent is string variable to store the html content
[Webview loadHTMLString:m_strHtml baseURL:Nil];
Webview.backgroundColor=[UIColor clearColor];
您可以使用輕觸手勢識別器。 – rishi
請檢查我的[問題] [1] [1]:http://stackoverflow.com/questions/10945439/detect-click-on-nsurl-on-uitextview 希望它會幫助你。 謝謝 –