1

在我的应用程序中,我想在 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"

任何人都可以帮助我如何做到这一点?

4

4 回答 4

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。

于 2013-03-02T06:16:54.420 回答
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];
于 2013-03-02T06:19:57.480 回答
0
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if ( inType == UIWebViewNavigationTypeLinkClicked ) {
        [[UIApplication sharedApplication] openURL:[inRequest URL]];
        return NO;
    }

    return YES;
}
于 2013-03-02T06:15:07.483 回答
0

试试这个,viewcontroller.h

 IBOutlet UIWebView *webView;

视图控制器.m

    NSString *strHtml = @"<a href=\"http://www.youtube.com/watch?v=pii4G8FkCA4/\">click here to see the link</a>";
[webview loadHTMLString:strHtml baseURL:nil];
于 2013-03-02T06:29:01.080 回答