问题描述
- UIWebView中自定义字符串值
- 最近开发的应用需要显示URL链接,在UIWebView中显示""Click here to see the link""。
For ex: link: http://www.youtube.com/watch?v=pii4G8FkCA4 在这显示 ""click here to see the link""
谢谢!
解决方案
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType { if ( inType == UIWebViewNavigationTypeLinkClicked ) { [[UIApplication sharedApplication] openURL:[inRequest URL]]; return NO; } return YES;}
解决方案二:
用下面的代码就能实现了:
UIWebView *webview=[[UIWebView alloc]init]; webview.frame=CGRectMake(0 0 320 480); NSString *html = @""<a href=""www.youtube.com/watch?v=pii4G8FkCA4"">click here to see the link</a>""; [webview loadHTMLString:html baseURL:nil]; [self.view addSubview:webview];
时间: 2024-11-01 20:23:27