0

得到了我作为字符串插入到 uiwebview 的这个 html

<div style="font-family: sans-serif;">

<p><p><u>George Barret</u>&nbsp;</p>

<p>Irish,
1728/1732-1784&nbsp;</p>

<p><b><i>An Extensive Wooded River Landscape
with Fishermen Hauling in their Nets in the Foreground</i></b><b>, </b></p>

<p><b>1760s</b></p>

<p>Oil on canvas<br><span style="font-size: 13.513513565063477px; line-height: 19.988739013671875px;">137 x 195.5 cm</span></p>

<p>Heritage Gift, IIB Bank, 2005</p>

<p><span>NGI.4750</span></p></p></div>

我在“1728/1732-1784”上有一个蓝色超链接

任何人都知道为什么以及如何禁用此行为?

谢谢

4

1 回答 1

1

myWebView.dataDetectorTypes = UIDataDetectorTypeNone;

这将阻止您UIWebView将任何内容(电话号码、链接、电子邮件地址)转换为可点击的链接。该属性detectorTypes是一个位掩码,您可以指定以下任何或所有值 OR'd 一起:

 enum {
   UIDataDetectorTypePhoneNumber   = 1 << 0,
   UIDataDetectorTypeLink          = 1 << 1,
   UIDataDetectorTypeAddress       = 1 << 2,
   UIDataDetectorTypeCalendarEvent = 1 << 3,
   UIDataDetectorTypeNone          = 0,
   UIDataDetectorTypeAll           = NSUIntegerMax
};

例如,要将电子邮件地址和电话号码转换为可点击的链接,您可以使用:

myWebView.dataDetectorTypes = 
    UIDataDetectorTypePhoneNumber | UIDataDetectorTypeAddress;
于 2013-03-28T17:53:46.053 回答