iOS开发:如何强制UIWebView加载非移动版Facebook? [英] iOS Development: How can I force a UIWebView to load the non-mobile version of Facebook?

查看:131
本文介绍了iOS开发:如何强制UIWebView加载非移动版Facebook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在深入研究iOS开发,当我尝试在UIWebView中加载特定的Facebook粉丝页面时,它会加载该网站的移动版本,该版本仅加载粉丝页面的墙壁而不是我的特定标签需要加载。在我的应用程序的iPad版本中,UIWebView加载了正常的非移动版本的Facebook,它加载选项卡就好了。如何强制iPhone上的UIWebView加载正常版本的Facebook?

I'm diving into iOS development and when I try to load a specific Facebook Fan Page in a UIWebView, it loads the mobile version of the site, which only loads the wall of the Fan Page instead of a specific tab that I need loaded. In the iPad version of my app, the UIWebView loads the normal, non-mobile version of Facebook and it loads the tab just fine. How can I force the UIWebView on the iPhone to load the normal version of Facebook?

推荐答案

Facebook最有可能分析用户代理确定要服务的版本。如果是这种情况,那么将用户代理更改为桌面浏览器用户代理将导致facebook更改提供的页面版本。您可以像这样更改NSMutableURLRequest上的用户代理:

Facebook is most likely analyzing the user agent to determine which version to serve. If this is the case then changing the user agent to a desktop browser user agent would cause facebook to change which page version is served. You can change the user agent on NSMutableURLRequest like so:

[request setValue:@"some-user-agent" forHTTPHeaderField:@"User_Agent"];

这篇关于iOS开发:如何强制UIWebView加载非移动版Facebook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆