Breaking News
Home / iOS / iOS Snippets / How to create and load URL in UIWebview in iOS?

How to create and load URL in UIWebview in iOS?

  1. // NSURL class is used to create an object which will hold the URL information.
  2.  
  3. // NSURLRequest is used to create a request to the URL.
  4.  
  5. // Method loadRequest of UIWebView is used to load the request in the UIWebView.
  6.  
  7.  
  8. (void)viewDidLoad {
  9.  
  10. UIWebView *webView =[[UIWebViewalloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];
  11.  
  12. webView.scalesPageToFit = YES;
  13.  
  14. NSString *urlAddress = @”http://www.google.com”;
  15. //Create a URL object.
  16. NSURL *url = [NSURL URLWithString:urlAddress];
  17. //URL Requst Object
  18. NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
  19. //Load the request in the UIWebView.
  20. [webView loadRequest:requestObj];
  21.  
  22. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger