【问题标题】:I want the href links in my simple help page to open in safari我希望我的简单帮助页面中的 href 链接在 safari 中打开
【发布时间】:2014-02-03 10:41:18
【问题描述】:

我的目标是 iOS 7.0.4,因为这是当前版本。我的应用程序中有一个帮助页面,它只是 html。我在那里有链接到我们公司的网站,但我不希望它们在应用程序中打开,我想启动 safari。

我尝试了这个问题的所有内容: How to open Safari from a WebApp in iOS 7

没有什么真正有效的。

该链接在应用程序中不断打开,这意味着没有浏览器的好东西,例如后退按钮或网址栏,甚至捏缩放看起来都很奇怪。

下面是相关的html代码行:

<p style="font-family:arial;font-size:60px;">Visit us on the web at 
<a href="http://ourcompany.com" target="_xxx">ourcompany.com</a>

我在target 中尝试了很多东西,例如"_new""_blank",或者根本没有。

这是加载 html 的代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSString *path = [[NSBundle mainBundle] pathForResource:@"capitalsHelp" ofType:@"html"];
    NSURL *targetURL = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [_webView loadRequest:request];
}

【问题讨论】:

  • 这会有帮助吗? this。你不是在做一个我不认为的网络应用程序,所以......试试看?
  • 不,这只是我用来寻求帮助的一个简单的 html 页面。
  • 请发布您当前的代码。

标签: html ios ios7 safari mobile-safari


【解决方案1】:

假设您使用 UIWebView 来呈现 html,您可以执行以下操作:

- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    if (navigationType == UIWebViewNavigationTypeLinkClicked ) {
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
    }

    return YES;
}

在 UIWebView 的委托上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 2015-11-02
    • 1970-01-01
    相关资源
    最近更新 更多