带有 UILabel 的 UIScrollView - 文本适合视图但图像不适合 [英] UIScrollView with UILabel - text fits view but images don't
问题描述
我有一个滚动视图,上面固定了一个文本标签.文本标签包含 html 属性文本(由
您遇到的问题是图像采用原始大小.
您应该在 html 中设置图像的最大宽度,如下所示:
I have a scroll view with a text label pinned to it. The text label contains html attributed text (converted by using the accepted answer here) which includes images such as graphs. I'm able to get the text to fit on screen, but the images are being cut off on the trailing side
Edit: The image is being pulled in like so:
<p><img src="https://lh5.googleusercontent.com/ZhaF0f-JiPOmvvFS4qor -gVpqFALuXcbwM8bBHIB 0I9dFRoUZkxQUx5G-0Cb PcuRNnC2Zw0Ty3lp9Ykr 3X00Iy0RfiLVJnsLP9Fu C_wORRhixVd3fm5JA27I MUTkFPf1JkZvLBFW" style="border:none; height:324px; width:624px" /></p>
Edit: The Scroll View's width is fixed because I'm only wanting it to scroll vertically
Edit: Constraints are set in storyboard if that matters
The problem you have is the image takes its original size.
You should set the max width of the image in the html, like so :
<img style="max-width: 100%;" src="mysrc.jpg" />
这篇关于带有 UILabel 的 UIScrollView - 文本适合视图但图像不适合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!