iOS UIWebView of RSS to look more like Safari and stay inside app

别来无恙 提交于 2019-12-05 11:48:22

You need to create an XML Parser. The UIWebView does not have the same capabilities as Safari. The best XML parser I found is here: https://github.com/mwaterfall/MWFeedParser

Yunus Emre Tırnovalı

You need to implement a url that must be different than the baseurl.

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";
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];
[self.article loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:URL];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!