-1

Below is the code i have tried:

 HTMLBrowserViewController.h
 IBOutlet UIWebView * webControl;

 HTMLBrowserViewController.m

 webControl.scalesPageToFit = YES;

webControl.contentMode = UIViewContentModeScaleAspectFit;

webControl.delegate = self;

NSURL *url1=[NSURL URLWithString:webUrl];

NSURLRequest *requestObject=[NSURLRequest requestWithURL:url1 cachePolicy:NSURLCacheStorageAllowed timeoutInterval:15];    

[webControl loadRequest:requestObject];
Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51

3 Answers3

1

If you are trying to load an HTTP URL only, please check and enable the AllowArbitaryLoad In the App Transport Security Settings in the info.plist. You can refer to the following link.

Transport security has blocked a cleartext HTTP

If you are using the https URL, please make sure the URL is loading fine in the Safari and as well as in the Chrome browser responsive mode.

Sometimes, the website will load the response URL in iFrame. so please check that pass the correct URL.

Also, print the URL before you pass to the UIWebView, sometimes it should have space and as well as & so remove the same and pass it in the WebView.

serviceBookingUrl = [
    NSURLRequest requestWithURL : [
        NSURL URLWithString : [
            websiteURL stringByReplacingOccurrencesOfString : @ "&" withString : @ "&"
        ]
    ]
];
[PrimaryWebView loadRequest: serviceBookingUrl];
Raghul SK
  • 1,256
  • 5
  • 22
  • 30
Varun P V
  • 1,092
  • 1
  • 12
  • 30
0

Add NSAppTransportSecurity in your application .plist file

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict> 

Check this link transport Security has Blocked a cleartext HTTP

Community
  • 1
  • 1
Yogendra Girase
  • 631
  • 3
  • 15
0

try this :

  NSString *encodedString=[urlString       stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSLog(@"urlString %@",encodedString);

    NSURL *url = [NSURL URLWithString:encodedString];

    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    // Set delegete
    webView.delegate=self;

    //Load the request in the UIWebView.
    [webView loadRequest:requestObj];
Ashwini Chougale
  • 1,093
  • 10
  • 26