So, I have a subclass of UIWebView and in this UIWebView I will be displaying Mathematical Expressions using MathJax in Swift. What I want to do, is to use the WebView like a UILabel so I disable userInteraction and scrolling . I found this :
lview.loadLatexString(latexString: "Hello !")
lview.frame.size.height = 1
lview.frame.size = lview.sizeThatFits(CGSize.zero)
But that doesn't work. I have this :
And I want this :
I hope this clarifies my problem.
You can use for disabling the scroll of webview
and UserInteraction
myWebView.scrollView.isScrollEnabled = false
myWebView.isUserInteractionEnabled = false
Try with UITextView.
make scroll and user intrection disable, textview will resize according content. take sure you give proper constraint
let theString : String = "</p><img src='https://pbs.twimg.com/profile_images/655066410087940096/QSUlrrlm.png' width=100 height=100 /><h2>Subheader</h2>"
let theAttributedString = try! NSAttributedString(data: theString.data(using: String.Encoding.utf8, allowLossyConversion: false)!,options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
textview.attributedText = theAttributedString
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.