vugla / pshtmlview Goto Github PK
View Code? Open in Web Editor NEWPSHTMLView is a non scrollable WKWebView wrapper, adapt for using in UITableView and UIScrollView.
License: MIT License
PSHTMLView is a non scrollable WKWebView wrapper, adapt for using in UITableView and UIScrollView.
License: MIT License
html String "<meta name="viewport" content="initial-scale=1.0 "width=device-width user-scalable=no "/><style type="text/css"> * {max-width: 100%; !important;"}</style>
첨밀밀OST - 월량대표아적심 (등려군)
\n
web view frame = (0 0; 375 312);
PSHTMLView frame = (0 0; 375 296)
receive height = 296
is there are anything for fix
To fix constraint issues (messages in console), you should make following changes:
lazy private var htmlCell: PSHTMLCell = { [weak self] in
var cell = self?.tableView.dequeueReusableCell(withIdentifier: "HTMLCell") as! PSHTMLCell
cell.htmlView.delegate = self
cell.contentView.autoresizingMask = .flexibleHeight
return cell
}()
set cell's contentView's autoresizingMask to flexibleHeight in example where cell is instantiated.
and in PSHTMLView.swift, before activating webviewHeightConstraint, set it's priority to 999:
public var webView: WKWebView! {
didSet {
addSubview(webView)
webView.translatesAutoresizingMaskIntoConstraints = false
webView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
webView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
webView.topAnchor.constraint(equalTo: topAnchor).isActive = true
webView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
webViewHeightConstraint = webView.heightAnchor.constraint(equalToConstant: self.bounds.height)
webViewHeightConstraint.priority = UILayoutPriority(rawValue: 999)
webViewHeightConstraint.isActive = true
webView.scrollView.isScrollEnabled = false
webView.allowsBackForwardNavigationGestures = false
webView.contentMode = .scaleToFill
webView.navigationDelegate = self
webView.uiDelegate = self
webView.scrollView.delaysContentTouches = false
webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal
webView.scrollView.delegate = self
}
}
After this, there will be no more messages about breaking constraints. These breaking constraints won't affect to the user experience in any way, but in general, when I am working with something, I rather have it without errors/warnings if possible at any cost :)
Good work by the way, I made something similar and got a few good tips from your work.
Can you please help us with an example for this on a UITableView with different cells. I need to dequeue different cells which have html content on them. (Not all cells having same html content as in example). I tried doing that but the content behave absurdly due to cellForRowAtIndex being called again
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.