1

私は次のように NSString を持っています

NSString *textOutStations = [NSString stringWithFormat:@"Hello Everyone. Please check out website:<br> http://www.google.com/</br>"];

これをUIWebViewにロードするので、URLに以下のようにgoogle.comを表示したいと思います。

www.google.com

そのため、ユーザーがクリックするたびに、iPhone で Safari を開く必要があります。

4

4 に答える 4

1

これを試してみてください

NSString *textOutStations = @"<html><head><title></title></head><body><div> Hello Everyone. Please check out website:<br/> <a href=\"http://www.google.com/\"> http://www.google.com/ </a>  </div></body></html>";

[self.webView loadHTMLString:textOutStations baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];

これはあなたを助けるでしょう......

于 2013-10-10T14:25:29.703 に答える
1
NSString *textOutStations = [NSString stringWithFormat:@"Hello Everyone. Please check out website:<br> <a href=\"google.com\">http://www.google.com/</a>"];

[self.webView loadHTMLString:textOutStations baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];

次に、UIWebView デリゲートで:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    // Opening safari
    [[UIApplication sharedApplication] openURL:request.URL];

....
}
于 2013-10-10T14:26:32.630 に答える