[英]How can I open a php webpage with uiwebview?
I'm trying to open/display the rssfeed http://www.golfweekly.nl/rss.php in a uiwebview. 我正在尝试在uiwebview中打开/显示rssfeed http://www.golfweekly.nl/rss.php 。 But the screen stays blank.
但是屏幕保持空白。 Opening http://www.google.com will just show the google content.
打开http://www.google.com只会显示Google内容。
This is how my WebView.m file is looking: 这是我的WebView.m文件的外观:
// 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. //加载视图后,通常通过笔尖实现viewDidLoad进行其他设置。
- (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];
}
Your URL above serves an RSS and not a HTML page. 您上面的网址提供的是RSS,而不是HTML页面。 Main desktop browsers like firefox, ie, etc. have a feature to parse the RSS and render it to a user-readable form.
主要桌面浏览器(例如firefox等)具有解析RSS并将其呈现为用户可读形式的功能。 UIWebView does not have this feature as far as I know thus it can not load the page.
据我所知,UIWebView没有此功能,因此无法加载页面。 You will need to parse the RSS file yourself and generate a HTML page (or even table view contents, etc) based on it.
您将需要自己解析RSS文件并基于该文件生成HTML页面(甚至是表格视图内容等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.