Use UIKit and WebKit in Swift to implement web page navigation, page zoom, and app state restoration features.
Minimum deployment target: iOS 13.0
- WKWebView and bottom toolbar back/forward(/refresh) navigation buttons
- Start view with centered start button which load a URL in WKWebView full screen
- Top progress bar appear on loading a URL, fade out with animation on finishing loading
- Page zoom gestures
- Back/forward buttons navigation:
- Through WKWebView.backForwardList and between start view and WKWebView
- Corresponding enabled states of back/forward(/refresh) buttons
- Screen edge pan gestures navigation:
- Through WKWebView.backForwardList and between start view and WKWebView
- Corresponding enabled states of back/forward(/refresh) buttons
- Save/restore WKWebView navigation history between app launches
- Implemented all methods listed in the two articles About the UI preservation process and About the UI restoration process (demonstrated in the two diagrams below).
- Specified
restorationIdentifier
values ofViewController
, the rootUINavigationController
,ViewController.view
,ViewController.progressBar
, andViewController.webView
. - Specified
restorationClass
values ofViewController
. - Defined a Swift structure
BrowserState
that stores two propertieswebViewInteractionState
andfullWebViewVisibleState
for preserving and restoringViewController.webView.interactionState
(browsing history) andViewController.fullWebViewVisibleState
(webView visible state and back/forward button enabled states). - Store and load
BrowserState
records in the local file system with the help ofFileManager
. - State (browsing history) restoration does not work right now.
UI Preservation | UI Restoration |
---|---|
Load WKWebView:
First load | Refresh |
---|---|
wkwebview.mov |
refresh_button.mov |
WKWebView back/forward navigations:
Buttons | Gestures |
---|---|
wkwebview_back_forward_buttons.mov |
wkwebview_back_forward_gestures.mov |
Back/forward navigations between WKWebView and start view
Buttons | Gestures |
---|---|
start_view_back_forward_buttons.mov |
start_view_back_forward_gestures.mov |