Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing constraint issues #1

Open
oskarirauta opened this issue Dec 28, 2017 · 1 comment
Open

Fixing constraint issues #1

oskarirauta opened this issue Dec 28, 2017 · 1 comment

Comments

@oskarirauta
Copy link

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.

@ankit0812
Copy link

ankit0812 commented Dec 18, 2018

I am still getting these warnings
Can you suggest something else to resolve this?
Xcode 10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants