【问题标题】:Disabled format-detection for iPhone/iPad webapp not workingiPhone/iPad webapp 的禁用格式检测不起作用
【发布时间】:2011-03-20 00:43:01
【问题描述】:

我有一个 web 应用程序,它显示许多在 iPhone / iPad 上识别为电话号码的长数字。我使用了苹果参考中提到的元标记来禁用它:

<meta name="format-detection" content="telephone=no"/>

但是,如果我正常加载或重新加载页面,这将不起作用。当我使用 ajax 重新加载页面的一部分时,它突然起作用并且数字是普通文本。但是当我重新加载页面时,数字又是链接。如果 ajax 加载的内容与 ajax 请求之前的位置完全相同,也会发生这种情况。

如果我在浏览器(而不是 webapp)中查看页面,它从一开始就可以正常工作。

您知道为什么会发生这种情况,我该如何解决? 有没有其他方法可以强制数字不是链接。

感谢您的帮助。

【问题讨论】:

  • 我遇到了同样的问题 - 很烦人!

标签: iphone ipad web-applications


【解决方案1】:

尝试将其添加到 YourProjectAppDelegate.m

// ...

- (void)webViewDidStartLoad:(UIWebView *)theWebView 
{
    theWebView.dataDetectorTypes = UIDataDetectorTypeAll ^ UIDataDetectorTypePhoneNumber;    
    return [ super webViewDidStartLoad:theWebView ];
}

// ...

为我做了诀窍..

【讨论】:

  • 我把它放在我的 WebViewController.m 文件中,它也很好用。谢谢!
【解决方案2】:

我遇到过类似的问题,嵌入式网页在浏览器中运行良好,但在嵌入应用程序时出现了问题。这是由于元标记被应用程序本身的设置覆盖,请参阅http://developer.apple.com/iphone/library/documentation/uikit/reference/UIKitDataTypesReference/Reference/reference.html#//apple_ref/doc/c_ref/UIDataDetectorTypePhoneNumber

有帮助吗?

【讨论】:

  • 它不是原生应用程序中的嵌入式网页。这是一个 webapp = 自定义网页 = 纯 html + JS + css。
【解决方案3】:

您可能需要完成将应用添加到主屏幕的整个过程,以强制更新缓存。

你也有format-detection according to Apple's guide to Apple-specific meta tags 的正确代码,但它们没有元标记作为带有斜杠的自闭合:

<meta name="format-detection" content="telephone=no">

【讨论】:

    猜你喜欢
    • 2011-10-06
    • 2015-11-26
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多