I'm having issues with Large Titles collapsing after a webpage in WKWebView finishes loading. Here is GIF example of what happens.
I've looked all over the internet and found two posts that might point in the right direction:
prefersLargeTitles not always honored - Apple Developer Forums
prefersLargeTitles - Displays correctly for a split second then collapses - Reddit
I would like the Large Titles to appear and remain in place when the webpage loads. When the user scrolls up (goes down on the webpage), the Large Titles should collapse to the smaller version. If the user goes back to the top of the webpage, the Large Titles should appear again.
Here's the code I have set up for a 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)
}
}
A point in the right direction would be greatly appreciated! Might it have something to do with scrollView.contentInsetAdjustmentBehavior
?
Edit: Yes - I made sure Web View is the first view in Main.storyboard after Safe Area.