ios - 如何使 WebView 在 iPhone/iPad Retina 中工作

标签 ios iphone ipad uiwebview retina-display

我的 webview 代码有点问题。它完全适用于 iPhone 和 iPad 非视网膜版本,但无法让它与视网膜一起使用。

我在下面提供了我的代码...这里似乎有什么问题?

self.webView.delegate=self;
self.webView.scalesPageToFit = YES;
NSString *urlAddress = @"https://www.google.com/";

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

//URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[webView1 loadRequest:requestObj];
[self.view addSubview:webView];

我是一个业余程序员所以请原谅我。我已经进行了谷歌搜索,但未能找到答案,所以我在这里 :)

编辑:抱歉,信息不完整。它不在 xib 或 Storyboard中。此外,我遇到的具体问题是在视网膜中时,webview 立即打开和关闭,然后使应用程序崩溃。不要介意崩溃,因为我明白它为什么会发生。我只是担心它不能在视网膜显示器上工作,尽管它在非视网膜显示器上完全没问题。

我原来的代码是webView.delegate=self;而不是 self.webView.delegate=self;... 我只是更改了它,因为我做了一些随机测试。 :/

最佳答案

奇怪的是,您的代码在任何设备上都能正常工作,因为您的 UIWebview 实例中存在错误。应该是这样的,看看 addsubview 行你在做什么。

self.webView.delegate=self;
self.webView.scalesPageToFit = YES;
NSString *urlAddress = @"https://www.google.com/";

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

//URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[self.webView loadRequest:requestObj];
[self.view addSubview:self.webView];

关于ios - 如何使 WebView 在 iPhone/iPad Retina 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19173059/

相关文章:

ios - iOS 中 @available 命令的 Travis 错误

ios - "Undefined symbols for architecture arm64:"用于快速测试中的功能

javascript - HTML5 : Video on the iPad - Custom Zoom Control

ios - Phonegap 构建 (config.xml) 和 iPad 闪屏

ios - 以前的 UITableView 中的项目出现在新的 UITableView 中

iphone - 使用 UINavigationController setToolbarHidden :animated: 时如何调整 View 大小

ios - 使用 vDSP 复制阵列内容

iphone - 在 iOS 中将图像元数据写入 JPG/PNG 文件

javascript - 用于搜索产品的 Ebay.com 查询字符串是什么?

iphone - iPhone 的 Thrift 框架