albaba
albaba

Reputation: 151

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:

enter image description here

enter image description here

enter image description here

Sorry for the image quality.

Upvotes: 2

Views: 3722

Answers (1)

nhgrif
nhgrif

Reputation: 62062

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:

enter image description here

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:

enter image description here

Upvotes: 9

Related Questions