简体   繁体   English

如何使Three20的TTStyledTextLabel与外部图像配合使用?

[英]How can I make Three20's TTStyledTextLabel work with external images?

I found an old post in the three20 Google Group about external image support not being implemented yet, but that's a few months old and it looks like TTStyledText is trying to support external images in the newer releases. 我在three20 Google网上论坛上发现了一篇关于外部图像支持尚未实现的老帖子,但这已经有几个月了,而且看起来TTStyledText正在尝试在较新的版本中支持外部图像。

I'm pulling out my hair trying to figure out why it isn't working for me. 我正在拔头发,试图弄清楚为什么它对我不起作用。 To reproduce, you can change the sample text in the TTCatalog/ StyledTextTestController.m to point to an external image rather than a bundle image. 要进行复制,可以在TTCatalog / StyledTextTestController.m中将示例文本更改为指向外部图像而不是捆绑图像。 Stepping through, I can see that the image is actually downloaded over the network and once loaded, TTStyledText calls styledTextNeedsDisplay on its delegate (TTStyledTextLabel), but the display is never updated to show the new image. 逐步查看,我可以看到该图像实际上是通过网络下载的,并且一旦加载,TTStyledText就会在其委托(TTStyledTextLabel)上调用styledTextNeedsDisplay,但是该显示永远不会更新以显示新图像。

If I close the app and restart it, the image is loaded properly from the cache, but it never works when it has to download it inline. 如果我关闭该应用程序并重新启动它,则会从缓存中正确加载该图像,但是当它必须内联下载时,它将永远无法工作。 Has anyone found a solution to this problem? 有没有人找到解决这个问题的办法?

Ugh. 啊。 Figured it out. 弄清楚了。 You have to specify a height and width in your img tag or when it loads it has a has a rect of CGRectZero and doesn't show. 您必须在img标签中指定heightwidth ,或者在加载时具有CGRectZero且不显示的矩形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM