我們使用的代碼下面的線移動到Web視圖:無法UIWebView中移動到指定的部分iOS11(新iPad)
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.hash=\'#-1\';"]];
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.hash=\'#%@\';", index]];
但不知何故,此代碼不能在iPad上才能正常工作。這裏是我如何初始化網絡視圖:
webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[webView setDelegate:self];
[webView.scrollView setDelegate:self];
[webView setBackgroundColor:WHITECOLOR];
[webView setScalesPageToFit:YES];
[webView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview: webView];
有人可以請指導我如何調試它。
在iOS11'location.hash'似乎被打破,但它是一個簡單的解決這個。 使用通常的組合絕對 – shc