I have text to display in my application. The text contains links that must be interactive. I tried several solutions for creating tappable links in UITextViews and UILabels .
Finally, I decided to use webview. I pass the text to the web view and create the basic HTML wrapper around it, and everything is very bad. This is the same approach that Twitter uses for iPhone (aka Tweetie).
The only problem that I am facing right now is that if the text is too long, web browsing causes overflow and scrolling to view the cropped text. Secondly, if the text is too short, then there is a large area of ββwasted space below the web view.
Unlike Tweetie, I have more content under webview, and I want to avoid scroll overflow or wasted space. Web browsing is a subspecies of scrolling in any case, so the contents of the entire page can grow without the need to view profiles.
Is there any way to dynamically resize the web view so that it only matches the correct height based on the content?
I have tried many things so far, nothing seems like a solid solution:
sizeToFit does nothing (or most likely just sets the size of what the current frame is).sizeThatFits: returns its current size anyway.NSString sizeWithFont:constrainedToSize: not possible, since UIWebView and UIFont have different ideas about what size is 18.- Just talk about it. In my testing, I found that the webView with scaleFactor 1.0 and
scalesPageToFit set to NO , and the font size for the entire page set to 13.5pt (in CSS) displays text the same size as a UILabel with a UIFont size 18. If anyone will be able to explain that I would be grateful.
- In addition, in webView I use the CSS property
word-wrap: break-word; to prevent the webView from scrolling horizontally in long words or URLs. Because of this, the transfer behavior between webView and UILineBreakModeWordWrap completely different. Even using UILineBreakModeCharacterWrap does not give the same results.
Either there is no way to do this, or I'm stupid and skipping something simple. If anyone could give some insight, I would be very grateful. Thanks.
ios iphone uikit uiwebview font-size
Jasarien
source share