I'm trying to use a UIWebView to embed a mobile version of a site in my app. However, when I do the following:
NSURL *url = [NSURL URLWithString:webLink];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[self.webView loadRequest:request];
the full version of the site is loaded. Then when I click any of the links in this page, it will process the mobile version of the site (as I would like it to from the very beginning).
I've tried messing around with the user-agent, with no luck. I don't think it's looking at the user-agent to determine whether or not to load the mobile version of the page, because I set my Firefox user-agent to iPhone and it still proceeded to load the full version.
If it helps any, the site I'm trying to load is a message board, using IP Board 3.1.4. I tried looking online to see how it determines whether or not to display mobile versions, with no luck.
If the website does not have a full mobile version, there's NOTHING you can do. :(
I found the solution to my problem today.
I posted my problem on the IP Board support forum, and got a response back saying that the IP Board checks for either "iPhone" in the user-agent, or a "mobileApp" cookie. Since messing with the user-agent wasn't working for me, I went with the latter approach.
I put this code into my applicationDidBecomeActive method in my appdelegate:
PS: I found this cookie solution in another stackoverflow question about cookies.