2017-04-08 47 views
0

大小所以,我有的UIWebView的子類,在此的UIWebView我會在斯威夫特使用MathJax來顯示數學公式。我想要做的,就是使用WebView像UILabel所以我禁用用戶互動滾動。我發現這個:斯威夫特 - 規模的UIWebView來的內容

lview.loadLatexString(latexString: "Hello !") 
lview.frame.size.height = 1 
lview.frame.size = lview.sizeThatFits(CGSize.zero) 

但這並不起作用。我有這個

而且我想這

我希望這個澄清我的問題。

回答

0

您可以使用禁用的webview滾動和UserInteraction

myWebView.scrollView.isScrollEnabled = false 
    myWebView.isUserInteractionEnabled = false 
0

與UITextView的嘗試。

使scroll和user introction禁用,textview將根據內容調整大小。確保你給予適當的限制

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