Reputation: 243
I got my uiwebview working and displaying the specified url. the only problem is that the webpage that comes up is not the mobile webpage but the normal webpage. The same url in mobile safari opens the mobile version of the webpage but in my app it opens the normal version. Anyone know a reason for this? I am using storyboard if thats any help
Here is a snippet of my code:
NSURL *url = [NSURL URLWithString:website];
[webview loadRequest: [NSURLRequest requestWithURL:url]];
Upvotes: 1
Views: 3451
Reputation: 17478
You could see if there is a URL parameter you could add in for this specific site since they don't seem to check for the UIWebView agent when deciding to show mobile.
E.G. Maybe going to www.theirsite.com?mobile=true would accomplish it.
Upvotes: -1
Reputation: 69459
UIWebView
does not send the same browser header as Safari, thus the web-server does not know which page to serve you app.
You could add an custom header to try and fix the problem.
NSURL *url = [NSURL URLWithString:website];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:@"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3" forHTTPHeaderField:@"User-Agent"];
[webview loadRequest: request];
Upvotes: 4