UIWebView content not adjusted to new frame after rotation

前端 未结 2 367
情话喂你
情话喂你 2021-01-22 14:22

I have an e-mail application,
which shows the content in an UIWebView inside an UISplitViewController.
Everything works fine until i rotate the

2条回答
  •  攒了一身酷
    2021-01-22 15:19

    i managed to solve it by updating the viewport width after rotating the device

    CGFloat fll_width = self.view.frame.size.width;
    NSString* adsl_javascript_string = [NSString stringWithFormat:@"var setViewPortScript = document.createElement('meta');\
         setViewPortScript.setAttribute('name', 'viewport');\
         setViewPortScript.setAttribute('content', 'width = %f');\
         document.getElementsByTagName('head')[0].appendChild(setViewPortScript);", fll_width];
    [adsc_webview stringByEvaluatingJavaScriptFromString:adsl_javascript_string];
    

提交回复
热议问题