0
votes

I’m building an article reading app for iPad and using split view controller.
UIViewController contains uiscrollview as a subview and uiscrollview contains uiwebview as subview and three labels.
I have disabled the scroll of uiwebview and set the scroll height according to the content size of uiwebview and labels in uiscrollview.
i’m facing a problem when i change the orientation portrait to landscape my content in uiweview is lost partially.

enter image description here

here is my code:

   - (void)webViewDidFinishLoad:(UIWebView *)webView
     {
      CGSize mWebViewTextSize = [webView sizeThatFits:CGSizeMake(1.0f, 1.0f)];  // Pass about any size

      CGRect mWebViewFrame = webView.frame;
      mWebViewFrame.size.height = mWebViewTextSize.height;
      webView.frame = mWebViewFrame;
      webView.scrollView.scrollEnabled = NO;
      webView.scrollView.bounces = NO;
      scroller.translatesAutoresizingMaskIntoConstraints  = NO;
      webView.translatesAutoresizingMaskIntoConstraints = NO;

     scroller.contentSize = CGSizeMake(scroller.frame.size.width, webView.frame.size.height+260);

   for (id subview in webView.subviews)
     {
       if ([[subview class] isSubclassOfClass: [UIScrollView class]])
      {
        [subview setBounces:NO];
        [subview setScrollEnabled:NO];

            }
         }
      }
1

1 Answers

0
votes

You need to adjust the frame of the WebView According to the orientation of iPad, TRy to adjust the frame of Webview as per the view Frame on UIInterfaceOrientation and reload the webview