【发布时间】:2011-12-12 16:26:28
【问题描述】:
我在 iPad 应用中有一个 UIWebView,应该显示移动 Google。它像 iPhone 一样宽 320 像素,我已经设置了用户代理,以便它加载移动 Google。但是该网站比 UIWebView 更宽,尽管该网站针对移动屏幕进行了优化。 这是我创建 Web 视图的代码:
NSDictionary *userAgentDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:userAgentDictionary];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 480)];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
[webView loadRequest:request];
[self addSubview:webView];
现在是这样的:
我可以做些什么来使它适合?它也应该适用于其他非移动页面。
【问题讨论】: