I added same subviews in the UIWebView's scrollview.When the webview get contentSize the scrollview will scroll to top.Now I'know the event happend before finished(some images may still loading) but after get the text content.What should i do?
This is the code,and to see the bug you need slow down the request(use edge)!! Before load finished scroll the view,then wait.When the request finished you will see the view scroll to top .
class WebViewController: UIViewController {
var mw = UIScreen.mainScreen().bounds.width
var mh = UIScreen.mainScreen().bounds.height
override func viewDidLoad() {
super.viewDidLoad()
var web = UIWebView(frame: CGRect(x: 0, y: 0, width: mw, height: mh))
var scrollview = web.scrollView
var tmp = UIView(frame: CGRect(x: 0, y: 0, width: mw, height: 300))
tmp.backgroundColor = UIColor.redColor()
scrollview.addSubview(tmp)
(scrollview.subviews.first as UIView).frame.origin.y = 300
let requestURL = NSURL(string: "http://stackoverflow.com/questions/27008545/how-to-disabled-uiwebview-auto-scroll-to-top-when-finished-load")
let request = NSURLRequest(URL: requestURL!)
web.loadRequest(request)
self.view.addSubview(web)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}