uiwebview not resizing after changing orientation to landscape

后端 未结 2 1564
轮回少年
轮回少年 2020-12-16 02:48

I\'m coding an iPhone app in which I have a UIWebView that loads a website with a responsive design.

The problem I have is when I rotate the devices to

相关标签:
2条回答
  • 2020-12-16 03:21

    Try setting constraints on the UIWebView. When the View rotated, the space constraints should automatically adjust.

    In the storyboard, look for the menu icons in the lower right. Select the auto layout icon (looks like a tie fighter), and then select either 'Add Missing Constraints' or 'Reset to Suggested Constraints'. enter image description here

    0 讨论(0)
  • 2020-12-16 03:30

    finally, this solved my problem

    - (void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
       [self.myWebView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    }
    
    0 讨论(0)
提交回复
热议问题