Answer the question
In order to leave comments, you need to log in
How to solve dynamic height UIWebView issue with ScrollView?
Please help me understand dynamic UIWebView. There is a controller with the following constraints (constraints)
The controller itself:
import Foundation
import UIKit
class ViewOnePageController : AbstractChildController, UIWebViewDelegate{
@IBOutlet weak var titletext: UILabel!
@IBOutlet weak var date: UILabel!
@IBOutlet weak var web: UIWebView!
var page : OtherPage!
override func viewDidLoad() {
super.viewDidLoad()
titletext.text = page.title
date.text = "Last Updated: "+Convertor.dateToString(page.parseDate/1000)
web.delegate = self
web.scrollView.scrollEnabled = false
web.scrollView.bounces = false
web.scrollView.showsHorizontalScrollIndicator = false
web.scrollView.showsVerticalScrollIndicator = false
for subview in web.subviews {
if subview.isKindOfClass(UIScrollView) {
for shadowView in subview.subviews {
if shadowView.isKindOfClass(UIImageView) {
(shadowView as UIView).hidden = true
}
}
}
}
web.loadHTMLString(page.text, baseURL: nil)
}
func webViewDidFinishLoad(webView: UIWebView) {
if let output:NSString! = webView.stringByEvaluatingJavaScriptFromString("document.height;") {
if let height:Double = output.doubleValue {
let heightConstraint = webView.constraints[0] as NSLayoutConstraint
// here is to update the height of UIWebView
heightConstraint.constant = CGFloat(height)
}
}
}
override func getTitle() -> String {
return page.title
}
override func back() {
self.navigationController?.popViewControllerAnimated(true)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question