Jump to content

UIWebViews


bR34Kr

3 posts in this topic

Recommended Posts

Posted

Hey there! Today we will learn how to make a UIWebView. A UIWebView is an asset in an app that displays a web page. Let's get started :)

Note that we will not create an application, we will add an asset to it. That means your projects needs to be setup before doing this.

 

Declaration:

UIWebView *webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , self.view.frame.size.height)] autorelease];

So with our UIWebView *webView we declare a UIWebView named webView. Our CGRect make spawns the view at 0, 0 and makes it the same size as the screen. So on any device it will resize to the screen size (y) Because self.view.frame.size.xxx specifies what it does, since Obj C uses dot notation we can read it as it follows:

self.view.frame.size.height = Get height from the size of the frame of the view (Load view)

 

Calling our website and displaying it:

webView.scalesPageToFit = YES;
[self.view addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.iosgods.com"]]];

We will add this under our existing code. So we scale the page to fit and we subview our UIWebView. The next line calls the website to be loaded, so I put iOSGods.com to display iOSGods.com in the app :) 

 

Hope you learned a thing or two from this and if you have any questions ask it in the comments :happydance: 

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines