Reputation: 13
I have made a baseViewController which is derived from UIViewController, SlideMenuDelegate and UIWebViewDelegate Then I have created subclass which are derived from baseviewcontroller
Everything is fine except that webview is not scrolling at all.
I have tried everything suggested in all posts so far regarding scrolling Below is my code written in PlayVC.swift
@IBOutlet weak var web1: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
addSlideMenuButton()
let webUrl : URL = URL(string: "http://brainyknights.com")!
let webRequest : URLRequest = URLRequest(url: webUrl)
web1.scalesPageToFit = true
web1.isUserInteractionEnabled = true
web1.scrollView.isScrollEnabled = true
web1.loadRequest(webRequest)
// Do any additional setup after loading the view.
}
Upvotes: 0
Views: 532
Reputation: 20804
According Apple Documentation
scalesPageToFit
A Boolean value determining whether the webpage scales to fit the view and the user can change the scale.
if web1.scalesPageToFit
is true
then the web content will fit in your UIWebView
frame and the contentSize
will have the same height and width as your UIWebView
frame making imposible to be scrollable
so remove this line and must work
web1.scalesPageToFit = true
I hope this helps you
Upvotes: 1
Reputation: 1110
remove this line web1.scalesPageToFit = true
@IBOutlet weak var web1: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
addSlideMenuButton()
let webUrl : URL = URL(string: "http://brainyknights.com")!
let webRequest : URLRequest = URLRequest(url: webUrl)
//web1.scalesPageToFit = true
web1.isUserInteractionEnabled = true
web1.scrollView.isScrollEnabled = true
web1.loadRequest(webRequest)
// Do any additional setup after loading the view.
}
Upvotes: 4