UIWebView Error in iPhone - objective-c

I am getting this error in webview while loading this url : http://www.thumbzine.com/rssfeed.php?vol=104
"Error Domain=WebKitErrorDomain Code=102 UserInfo=0xde6ce0 "Frame load interrupted""
[webView loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:#"thumbzine.com/rssfeed.php?vol=104"]]];
What is this error due to ?
Thanks

Try this
NSString *urlText = [NSString stringWithString:#"http://www.thumbzine.com/rssfeed.php?vol=104"];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];

Related

URLWithString return null

My code must update web view and download web site. But it doesn't because URLWithString returns null. How can I solve this problem? stringByAddingPercentEscapesUsingEncoding is already deprecated.
-(void) setWebViewMain:(NSString *) link {
// link = #"http://www.rbc.ru/society/05/09/2017/59ae2dfe9a794753f05e3e06"; if this string uncomment code is working
NSURL *url = [NSURL URLWithString: link];
NSLog(#"%#",url); // here url is (null)
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
[self.webView reload];
}
try as
-(void) setWebViewMain:(NSString *) link {
// link = #"http://www.rbc.ru/society/05/09/2017/59ae2dfe9a794753f05e3e06"; if this string uncomment code is working
NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:#"%#",link]];
NSLog(#"%#",url); // here url is (null)
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
// [self.webView reload];
}
Just remove the last line from your method and it will work:
-(void) setWebViewMain:(NSString *) link {
// link = #"http://www.rbc.ru/society/05/09/2017/59ae2dfe9a794753f05e3e06"; if this string uncomment code is working
NSURL *url = [NSURL URLWithString: link];
NSLog(#"%#",url); // here url is (null)
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
//[self.webView reload];
}
You can call it like this:
[self setWebViewMain:#"http://www.rbc.ru/society/05/09/2017/59ae2dfe9a794753f05e3e06"];

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];
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];
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
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];

xcode 5, and 4.6.3 Can't load a rtfd.zip file into UIWebView

Prior to upgrading to xcode 4.6.3 the following code worked perfectly. Now it does NOT. I get a blank white page. This code is placed after super viewDidLoad:
NSString *path = [[NSBundle mainBundle]pathForResource:#"info.rtfd" ofType:#"zip"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[webView setScalesPageToFit:YES];

UIWebView doesn't load content

I don't understand why if I load the content of a UIWebView in XCode this way:
NSString *string = #"http://www.dummyurl.org/dummy.pdf";
NSURL *url = [NSURL URLWithString:string];
[my_view loadRequest:[NSURLRequest requestWithURL:url]];
everything works fine, but if a build the original string from a php script I wrote:
NSString *strURL = [NSSTring stringWithFormat:#"www.myserver.php"];
NSString *string = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:strURL]];
NSURL *url = [NSURL URLWithString:string];
[my_view loadRequest:[NSURLRequest requestWithURL:url]];
nothing works. I checked my script and it returns EXACTLY the original string (http://www.dummyurl.org/dummy.pdf) that works fine with the first method.
I build from a PHP script the content of a UITextView too, but that works fine.
I don't understand why this method works with the UITextView but not with the UIWebView to load the .pdf.
It may be useful
NSCharacterSet *characterSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *tempString = [string stringByTrimmingCharactersInSet:characterSet];
NSURL *url = [NSURL URLWithString:string];
[my_view loadRequest:[NSURLRequest requestWithURL:url]];
Make sure you linked the webview (IBOutlet) and the delegate.
With this lines it should load a url:
webView.delegate = self;
NSURLRequest *urlRequest;
NSString *urlToOpen = [NSString stringWithFormat:#"http://www.stackoverflow.com"];
urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:urlToOpen]];
[self.webView loadRequest:urlRequest];
Hope this helps...
I had this and it was a cache problem:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];

reading excel sheet with url in Iphone sdk

I am Having a problem here.I am downloading the excel sheet using Url and have to displaying it in the web view here my problem is the Excel sheet is not displaying.
I written the code as:
NSString *str = #"";
str = [str stringByAppendingString:
#"http://databases.about.com/library/samples/address.xls"];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
[webView loadData:data MIMEType:#"application/xls" textEncodingName:#"UTF-8"
baseURL:[NSURL URLWithString:#"http://google.com"]];
[contentView addSubview:webView];
Thank you,
Monish.
Are you able to view it using Safari on the phone or does it say "unsupported format"?
Try another file that works in Safari and then try in UIWebView.
Also see this: http://developer.apple.com/iphone/library/qa/qa2008/qa1630.html
First make sure you are able to view the xls in Safari then try code like this:
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:#"http://www.yourwebsite.com/good.xls"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}