Here is my code, it doesn't seem to work for RSS pages, but works fine for google.com (or any other plain old web page), any idea why?
UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0, 510, 1024, 230)];
NSURL *url = [[NSURL alloc] initWithString:#"http://feeds.marketwatch.com/marketwatch/topstories/"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[wv loadRequest:request];
The Marketwatch RSS URL you are using in your example returns XML, not HTML. The reason it looks like HTML when you view it in a browser is that it has an xml-stylesheet attached to it that the browser is using to render a human-readible view. However the UIWebView component does not do the same thing.
For your purposes you'd probably want to request this XML, parse it, and use the contents in a UITableView.
Related
I am using UIWebview to load a weburl, which contains few images and text. But after loading the url on webview images gets replaced with one another on some devices.
Is it problem with webpage?
My Code is here
NSURL *url=[[NSURL alloc]initWithString:_url];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
I have attach link to the actual loaded webview.
this image actually appears to some other location but right now it gets loaded to this place
Try to this one , it may help you..!!
https://github.com/AdrianFlorian/AFImageViewer
Images url are old, please replace with other like:
#image url: http://www.citi.io/wp-content/uploads/2015/10/1291-01-bruges-meteoweb.eu_.jpg
-(NSArray *)imageUrls
{
return [NSArray arrayWithObjects:
[NSURL URLWithString:#"http://imgs.mi9.com/uploads/landscape/4717/free-the-seaside-landscape-of-maldives-wallpaper_422_84903.jpg"],
[NSURL URLWithString:#"http://pics4.city-data.com/cpicc/cfiles42848.jpg"],
nil];
}
I am loading one URL in UIWebView. It calls webViewDidFinishLoad delegate method but load an error page.
To load URL, I have used below code:
[customwebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:customURL]]];
Then I tried same URL in the Safari browser and it gets perfectly loaded.
This is the case only with iPhone4 with iOS 7.1.2.
I tried in simulator and device. Result is same.
Is there anything I need to set manually to load URL in UIWebView which is bydefault ON in Safari?
i was also not able to load urls like Facebook share dialog and twitter share.
But i got it fixed by encoding the url
use this :
NSString *encoded = [self.link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:encoded]];
self.webView.delegate = self;
[self.webView loadRequest:request];
I am trying to open a PDF file in my app Bundle on Safari. I can open this PDF with applications like iBooks or other PDF readers. However I cant get it to open it with safari. Is there any way in which i can achieve this? I tried OpenURL but that doesnt work???
Why don't you open in uiwebview?
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
NSURL *targetURL = [NSURL URLWithString:#"http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIWebView_Class/UIWebView_Class.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView release];
You can't open that in Safari since iOS apps are sandboxed. The solution available now would be to open the PDF using UIWebView or send it to another app that can handle PDF files.
I've a problem that i couldn't solve, i wanna run the Apple - HTML5 Showcase - Gallary
in UIWebView inside my ipad app.
I've tried a local html file:
NSString *strr = [[NSBundle mainBundle] pathForResource:#"photo-gallery" ofType:#"html"];
NSString *str = [[NSString alloc] initWithContentsOfFile:strr encoding:NSASCIIStringEncoding error:nil];
NSLog(#"%#",str);
[webView loadHTMLString:str baseURL:nil];
and also a server html file, but it didn't work, can anyone help me, i wanna show an html5/css3 in UIWebView.
thx in advance.
hi this is what you can do
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:webFrame];
//getthe path of the local html file
NSURL *baseURL = [NSURL fileURLWithPath:fileNamePath];
NSURLRequest *aRequest = [NSURLRequest requestWithURL:baseURL];
//load the html file into the web view.
[aWebView loadRequest:aRequest];
//add the web view to the content view
[view addSubview:aWebView];
For server html you simply skip the second line, and put the address.
Hope it helps
You can take a look at phonegap. Its a complete framework for building html5 apps inside a UIWebview with native capabilities.
See: http://www.phonegap.com
Hi i want to make a few http request and generate html from within my ipod app. I hear i want a WebView to view the html as if it were a browser. So my question is how do i make the http request? How do i parse json (or xml) and how do i save/load data? I figure i can use webstorage to load/save the data however i am thinking since its an ipod app i have a better way of storing it?
Here's a snippet to load a local html web page contained inside your app bundle:
UIWebView *webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
NSString *path = [[NSBundle mainBundle] pathForResource:#"mywebpage" ofType:#"html"];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
Another alternative is to embed a local web server running in a background thread, and use a URL to localhost.
A UIWebview supports HTML5 local storage.
Here is the working code snippet. for iPod/iPhone/iPad;
Works with iOS7 and iOS6.. I have not tested in others...
UIWebView *_webView = [[UIWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:_webView];
NSURL *url = [NSURL URLWithString:#"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];