gpt4 book ai didi

iphone - UIWebView 未加载移动网站

转载 作者:可可西里 更新时间:2023-11-01 06:16:04 26 4
gpt4 key购买 nike

我知道之前已经介绍过了,但是上面提到的方法都不适合我,

我需要 UIWebView 来加载移动网站,但它返回的是桌面版本

我试过了

NSMutableURLRequest *stadiumURLRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com/"]];
[stadiumURLRequest 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"];
[stadiumWebView loadRequest:stadiumURLRequest];

在 AppDelegate 中:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary];
[cookieProperties setObject:@"mobileApp" forKey:NSHTTPCookieName];
[cookieProperties setObject:@"1" forKey:NSHTTPCookieValue];
[cookieProperties setObject:@"www.example.com" forKey:NSHTTPCookieDomain];
[cookieProperties setObject:@"www.example.com" forKey:NSHTTPCookieOriginURL];
[cookieProperties setObject:@"/" forKey:NSHTTPCookiePath];
[cookieProperties setObject:@"0" forKey:NSHTTPCookieVersion];

NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
}

谢谢

最佳答案

你不必添加标题,它们是默认发送的,另外,看看它是否加载到 safari 中,这不仅仅是网站问题

关于iphone - UIWebView 未加载移动网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15023113/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com