0

It is very Common question but I stuck badly in the problem.My problem define in the screen shot below. enter image description here

I want to set the content inside the webview according to the screen width.I have a tableview Where a uiwebView on each tableView Cell.

I used many things like webView.scalesPageToFit = YES; and autoresizemask but can't solve it.

Any Help? Thanks in advance

rmaddy
  • 314,917
  • 42
  • 532
  • 579
taha027
  • 1,123
  • 13
  • 20
  • try this: https://stackoverflow.com/questions/36426007/scalespagetofit-for-webview-is-not-working-with-ios-9-3 – Daljeet Nov 29 '17 at 12:44

2 Answers2

0

In your case webView.scalesPageToFit = true but still webview not fit it seems to problem with tableviewcell size of webview maybe initially not found accurate reloading tableview may solve this issue try below code if that related to tableview reload this will help

override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.YOUR_TABLEVIEW.reloadData()
}

Hope this will help you

Ganesh Manickam
  • 2,113
  • 3
  • 20
  • 28
  • Thanks for the Fast response, The issue is raised when the webview.scrollview.contentsize.width > screen width , so i want a way to adjust the content w.r.t screen width because the scroll is disabled. – taha027 Nov 29 '17 at 09:10
  • `webView.scalesPageToFit = true` will help to set the same size – Ganesh Manickam Nov 29 '17 at 09:14
0

Try this method:

 -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
       //Access web view form cell here
       // then use [webObj sizeToFit];
       // then get height of web view and return it as height of cell

    }
Mangesh Murhe
  • 361
  • 1
  • 8