【发布时间】:2015-05-25 21:50:09
【问题描述】:
我正在展示一个使用 DTCoreText 的 HTML 代码。到目前为止一切正常,但现在我在此 HTML 代码中收到嵌入的推文,但它们无法正常工作。 正如 Twitter 文档中所说,推文嵌入了块引用标签,这是我收到的一个示例:
<blockquote class="twitter-tweet" lang="fr">
<p>
Here is the official <a href="https://twitter.com/hashtag/SPECTRE?src=hash">#SPECTRE</a> teaser poster <a href="http://t.co/3cn3iM6tf1">pic.twitter.com/3cn3iM6tf1</a></div>— James Bond (@007) <a href="https://twitter.com/007/status/577877246809141248">17 Mars 2015</a>
</blockquote>
仅显示文本。 我以这种方式在 DTCoreText 中注册了一个新类:
[DTTextAttachment registerClass:[MyBlockquoteClass class] forTagName:@"blockquote"];
MyBlockQuoteClass 有这个构造函数:
- (id)initWithElement:(DTHTMLElement *)element options:(NSDictionary *)options
{
self = [super initWithElement:element options:options];
if (self)
{
NSLog(@"THIS IS MY ELEMENT %@", element);
NSLog(@"THESE ARE MY OPTIONS %@", options);
}
return self;
}
读取blockquote标签时调用构造函数,但options只有4个与字体颜色和大小相关的键,元素有很多属性但对我没用,几乎所有东西都是nil,没有孩子,只有get class="twitter-tweet" 和 lang="fr",但无法获取内容,因此我无法将块引用嵌入到 UIWebView 中。
我做错了什么?也许使用 DTCoreText 有更好的方法?
亲切的问候!
【问题讨论】:
标签: ios twitter dtcoretext