Swift how to design UIWebView Auto resize full screen in Story Board
In ViewDidLoad and when you use autolayout, the frame is not yet calculated.
So, place your code in viewDidLayoutSubviews or in viewDidAppear, and that should fix the bug.
You can also fix that, only by adding constraints in your interface builder (do not forget to remove your code in viewDidLoad) :
UIWebview full screen size
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.
How to full screen layout to a view in Swift?
You question is very vague. Maybe you messed up with your constraints? Try setting the constricts to the size of the screen instead of a specific height and width.
Make sure each thing is set to 0
How do I make a UIWebView's content adjust to the iPhone screen size?
The statement
webView.scalesPageToFit = YES;
should size the web page to fit the size of the UIWebView. The user then has the option to zoom in and out of the page. Your problem might be because the webview is not located properly. If your view controller's view fits the screen entirely, add this to your code.
webView.frame=self.view.bounds;
UiWebView display in fullscreen
Your UIWebView
already constrained to superView
but myWebView
's UIWebBrowserView
shows under the safeArea
.
By the way UIWebView
was deprecated, please check the link below.
Just change the UIWebView
to WKWebView
- Import
WebKit
import WebKit
- Initialize it
These Italian comments from OP's github repo so knowingly adding them here
//Definizione della UIWebView
var myWebView = WKWebView()
- Change
loadRequest
lines to
myWebView.load(request)
- In
viewDidLoad
myWebView = WKWebView(frame: CGRect(x: 0, y: 0,
width: view.frame.width,
height: view.frame.height))
And run!
BONUS
UIWebView is deprecated -> Apple Docs
WKWebView documentation -> Apple Docs
WKWebView usage ->Hackingwithswift
Related Topics
iOS 8 Swift Audio Playback Execute Method on Completion
Linking Error When Building Parse in Xcode 7
Updated Approach to Reauthenticate a User
"Ambiguous Use of 'Children'" When Trying to Use Nstreecontroller.Arrangedobjects in Swift 3.0
How to Stop an Infinitely Rotating Image? and How Does One Implement Removeallanimations
Composing Video and Audio - Video's Audio Is Gone
Empty Class in Swift Playground Gives _Lldb_Expr_ Error
Including Zeros in Front of an Integer
After Getting Image from Uiimagepickercontroller, Uiimageview Rotates Image for iPhone 5
Is There Difference Between Using a Constructor and Using .Init
How to Run App in Simulator Xcode 6
How to Display Mtkview with Rgba16Float Mtlpixelformat
Swift Package Manager with Resources Compile Errors
Differences Between Ways of Initializing a Dictionary
Swift Implement Literalconvertible Protocol