【发布时间】:2018-08-04 15:19:27
【问题描述】:
在 WKWebView 中的网页完成加载后,我遇到了大标题折叠的问题。 Here is GIF example of what happens.
我浏览了整个互联网,发现了两个可能指向正确方向的帖子:
prefersLargeTitles not always honored - Apple Developer Forums
prefersLargeTitles - Displays correctly for a split second then collapses - Reddit
我希望大标题在网页加载时显示并保持在原位。当用户向上滚动(在网页上向下滚动)时,大标题应该折叠成较小的版本。如果用户返回网页顶部,大标题应该会再次出现。
这是我为 WKWebView 设置的代码:
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string: "https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
非常感谢您指出正确的方向!会不会和scrollView.contentInsetAdjustmentBehavior有关?
编辑:是的 - 我确保 Web 视图是 Main.storyboard 中 Safe Area 之后的第一个视图。
【问题讨论】:
-
你最终做了什么来解决这个问题?
标签: ios swift xcode wkwebview preferslargetitles