I’m trying to open/display the rssfeed http://www.golfweekly.nl/rss.php in a uiwebview. But the screen stays blank. Opening http://www.google.com will just show the google content.
This is how my WebView.m file is looking:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *strWebPage = @"http://www.golfweekly.nl/rss.php";
NSURL *url = [NSURL URLWithString:strWebPage];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
[webViewBuienRadar loadRequest:requestURL];
[strWebPage release];
}
After some very usefull tip/response it works with the following code :
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString * userAgent = @"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+(KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3";
NSString * urlString = @"http://reader.mac.com/mobile/v1/http%3A%2F%2Fwww.golfweekly.nl%2Frss.php";
NSURL *URL = [NSURL URLWithString:urlString];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:URL];
[req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
NSURLResponse* response = nil;
NSError* error = nil;
NSData* data = [NSURLConnection sendSynchronousRequest:req
returningResponse:&response
error:&error];
[webViewBuienRadar loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:URL];
}
Please, refer to that post where you can find a suggestion allowing you to parse the incoming rss feed as the
UIWebviewwouldn’t not display it.Another nice solution there allows you to change your User Agent.