Jawad Sabir
Jawad Sabir

Reputation: 167

UIWebView is not responsive in iOS8 and Objective C

The following code was working properly in iOS7, Now with iOS8 it is not getting and result. What could be the reason and the answer?

   NSURLRequest *url = [[NSURLRequest alloc] initWithURL:[[NSURL alloc] initFileURLWithPath:[NSString stringWithFormat:@"https://www.facebook.com/1079798338712435"]]];
    [self.webView loadRequest:url];

Upvotes: 1

Views: 220

Answers (3)

Jawad Sabir
Jawad Sabir

Reputation: 167

I have solved it using html request instead of URL, I believe it is iOS8 bug. here is how I got the results

  NSString*url2 = [NSString stringWithFormat:@"https://www.facebook.com"];

    NSURL*url3 = [NSURL URLWithString:url2];

    NSString*htmlString = [NSString stringWithContentsOfURL:url3 encoding:NSUTF8StringEncoding error:nil];

    [self.webView loadHTMLString:htmlString baseURL:nil];

Upvotes: 0

Tony
Tony

Reputation: 4591

You got a mistake: do not use -[NSURL initFileURLWithPath:] with http link

I'm sure that url is nil when running your code, and your webview loaded a NIL url, so there is nothing happened

Use -[NSURL initWithString:] instead

Good luck

Upvotes: 2

Ashok Londhe
Ashok Londhe

Reputation: 1491

Use the following code and do proper connection:

NSString *stream=@"http://youtube.com";
NSURL *url=[NSURL URLWithString:stream];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];

Upvotes: 3

Related Questions