UIScrollView with UILabel - text fits view but ima

2019-08-24 04:27发布

问题:

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

回答1:

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" />