How to request the desktop version of a webpage in Swift 2

落花浮王杯 提交于 2020-01-07 03:53:07

问题


I've tried to request the desktop version of a webpage in this way but it doesn't work and I can't find anything on the web to help me

let url = NSURL(string: "*****")

let request = NSMutableURLRequest(URL: url!)

let newUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.6 Safari/537.11"

request.setValue(newUserAgent, forHTTPHeaderField: "User_Agent")

webView.loadRequest(request)

Could you please help me?

来源:https://stackoverflow.com/questions/34816464/how-to-request-the-desktop-version-of-a-webpage-in-swift-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!