UIWebview full screen size

纵饮孤独 提交于 2019-12-04 03:30:46

One cheap thing to do would be to set the frame of the webview in overriding - (void)viewDidLayoutSubviews

- (void)viewDidLayoutSubviews {
    webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}

the advantage of doing it here, is that the size and orientation of the view has already been determined here, and you can get an accurate measurement.

Using Auto Layout

Be sure the "Constrain to margins" option is not checked, all constrain values are 0:

And your webview is a first child of your main view:

Without Auto Layout

Change webview autosizing connections:

After a lot of headache dealing with compatibility of iOS6, 7 and different screen sizes, I use this one:

- (void)viewDidLoad {
   [super viewDidLoad];

   self.webview = [[UIWebView alloc] init];
   // More setting your webview here

   // Set webview to full screen
   self.view = self.webview;

   [self.webview loadRequest:aRequest]; 
}

I was able to get this working correctly for me by selecting the Reset to Suggested Constraints under the Resolve Auto Layout Issues menu.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!