UIScrollView with UILabel - text fits view but images don't

…衆ロ難τιáo~ 提交于 2019-12-12 04:02:40

问题


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


来源:https://stackoverflow.com/questions/44753628/uiscrollview-with-uilabel-text-fits-view-but-images-dont

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!