2
我把一個WebView放在一個tableViewCell中,我在tableView中使用它。到現在爲止一切工作正常。但是我爲WebViewCell使用了一個固定的大小。現在我想顯示WebView的所有內容。我改變了我的代碼,這一個在MyTbaleView
類在tableViewCell中添加一個Webview
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if let cell = modelCollection[collection.identifier] {
if let _ = cell as? TiteCell{
return 200
} else if let _ = cell as? myWebViewCell{
return UITableViewAutomaticDimension
}
}
func tableView(tableView: UITableView, EstimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 1000
}
,這是廈門國際銀行文件
有了這個代碼的WebView變得非常小,幾毫米。我想這個代碼,我在論壇發現添加到MyWebViewCell
類
func webViewDidFinishLoad(webView : UIWebView) {
var frame = myWebView.frame
frame.size.height = 1
myWebView.frame = frame
let fittingSize = myWebView.sizeThatFits(CGSize(width: 0, height: 0))
frame.size = fittingSize
myWebView.frame = frame
myWebView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
現在的WebView是有點大了1釐米×和寬度比iPad寬度。
Webview在tableviewcell?這是一個昂貴的過程,你必須考慮重新設計。如果你只想要富文本,你可以在UILabel中使用NSAttributedString。 –
我只是想從網上加載一個網頁,並在表格視圖單元格中顯示 – ella23
您是否試圖通過設置比例頁來適應屬性? – Sreekanth