【发布时间】:2016-08-05 05:10:23
【问题描述】:
我的手机升级到iOS 10 beta 3后遇到一个问题,当我在我的应用中缩放一个WKWebView时,缩放功能不仅会缩放网页的内容,还会缩放页面本身。
请看我附上的图片。 WKWebView that fails to zoom correctly.我将WKWebView的背景色设置为蓝色,当我捏缩小视图时,页面(容器?)本身也缩小了,导致不利的结果。 在 iOS9 中不会发生。 当我做同样的事情时,蓝色背景不显示。
该网页是用AngularJS 编写的,Graph lib 是d3js。
相关代码如下。
-(void) reloadWebPage{
[activityIndicator startAnimating];
NSString *indexToPath = [self getIndexHtmlPath];
NSURL *fileUrl = [NSURL fileURLWithPath:indexToPath];
NSURL *absoluteUrl = fileUrl.absoluteURL;
if(currentGroup == nil){
currentGroup = @"0";
}
NSString *absoluteString = [[absoluteUrl absoluteString] stringByAppendingFormat:@"%@%@", @"?currentGroup=", currentGroup];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:absoluteString] ];
[webView loadRequest:request];
}
- (void)createWebView{
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
[config.userContentController addScriptMessageHandler:self name:@"interOp"];
webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:config];
[webView setBackgroundColor:[UIColor blueColor]];
[webView setNavigationDelegate:self];
[webView setUIDelegate:self];
}
我不知道问题出在哪里?它是在 Objective C、iOS10 中还是在 Javascript 中?
请建议,我该如何解决这个问题?
谢谢
【问题讨论】:
-
您提到的链接旨在禁用缩放,我不想禁用它。另外我也没用
user-scalable=no。 -
好的,我知道了。可以给个问题页面的链接吗?
-
是的,我做到了。请参阅链接“无法正确缩放的 WKWebView”。在问题中。
标签: ios objective-c webview ios10