0

i'm in trouble. i'm currently using a uiwebview to display content. but i want to show content without scrolling in uiwebview.

Below the code. look it

func webViewDidFinishLoad(webView: UIWebView!) {

    var newBounds: CGRect = webView.bounds
    newBounds.size.height = webView.scrollView.contentSize.height
    webView.bounds = newBounds

}

but it won't be change its size. Anyone know what should i do ?

Thanks in advance.

Viju
  • 427
  • 1
  • 9
  • 16

2 Answers2

1

There is an option to automatically scale your content. Try this:

// Assumes 'webView' is a property
overload func viewDidLoad() {
    super.viewDidLoad()
    webView.scalesPageToFit = true
}

You can also set this property in the storyboard/xib. Note that this enables zooming.

Eric
  • 2,077
  • 17
  • 16
0

Try this code

 let webV:UIWebView = UIWebView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height))
 webV.loadRequest(NSURLRequest(URL: NSURL(string: "http://www.jogendra.com")))
 webV.delegate = self;
 self.view.addSubview(webV)

Thanks

Shanmugasundharam
  • 2,082
  • 23
  • 32