在我的应用程序中,我想在UIWebView中显示URL链接值为“点击此处查看链接”?
For ex: link: http://www.youtube.com/watch?v=pii4G8FkCA4
I want to show it as in UIWebView as "click here to see the link"
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
试试这个,
NSString *html = @"<a href=\"http://www.youtube.com/watch?v=pii4G8FkCA4/\">click here to see the link</a>";
[webview loadHTMLString:html baseURL:nil];
这将帮助您在webView中加载URL。
答案 1 :(得分:1)
尝试这样,你会得到,
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];
答案 2 :(得分:0)
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
答案 3 :(得分:0)
试试这个, viewcontroller.h
IBOutlet UIWebView *webView;
viewController.m
NSString *strHtml = @"<a href=\"http://www.youtube.com/watch?v=pii4G8FkCA4/\">click here to see the link</a>";
[webview loadHTMLString:strHtml baseURL:nil];