简体   繁体   中英

Adjusting height/width of UIWebview in Swift

I am using a UIWebview to display a web page (that's responsive in Safari) for a login portal but the width and height seem to be running off the screen. Universal, using Any Width, Regular height.

Images:

在此输入图像描述

在此输入图像描述

在此输入图像描述

Sorry for the image quality.

This can be prevented by adding some auto-layout constraints so that your web view will always take up the same portion of the screen no matter the device it runs on.

With the web view selected in interface builder, open up the constraints menu and add the appropriate constraints:

在此输入图像描述

Note that I unchecked the "Constrain to margins" as I want (and looks like you probably also want) your view to go all the way to the edges of the view controller.

When your done, the IB side menu should look about like this:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM