Code Monkey home page Code Monkey logo

pshtmlview's People

Contributors

safety97 avatar vugla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pshtmlview's Issues

Unable to dequeue cells with different HTML Content

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

Fixing constraint issues

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.