WordPress-Editor-iOS
WordPress-Editor-iOS copied to clipboard
Switch to WKWebView instead of UIWebView
Title has it. This is an iOS 8 only api, but we could consider regressing to UIWebView for iOS 7 users.
Marketing blurb:
WKWebView is the centerpiece of the modern WebKit API introduced in iOS 8 & OS X Yosemite. It replaces UIWebView in UIKit and WebView in AppKit, offering a consistent API across the two platforms.
Boasting responsive 60fps scrolling, built-in gestures, streamlined communication between app and webpage, and the same JavaScript engine as Safari, WKWebView is one of the most significant announcements to come out of WWDC 2014.
Mattt Thompson has a nice breakdown of it here: http://nshipster.com/wkwebkit/
I think this is worthwhile as there's a good chance we'll drop iOS 7 support.
This is a status message posted by @SergioEstevao in an initial/tentative PR. I'm posting this here for context:
Trying to upgrade the uses of UIWebView to WKWevView, here a list of main issues to solve:
- [x] Port the hack to have a read/write customAccessoryView from UIWebView to WKWebView
- [ ] ~~Remove unnecessary hacks~~ (EDIT by Diego: let's leave this for v2).
- [x] Make custom fonts load in the web view, because it looks it does;t have access to system ones.
- [ ] ~~Port javascript html schema callbacks to use WKUserContentController~~ (EDIT by Diego: let's leave this for v2)
Custom fonts are now loading in the web view.
I'll be implementing native callbacks in a separate branch named feature/260-wkwebview-native-callbacks. That way we can either decide to merge them as part of this PR or in a separate one.
When integrating this into WPiOS we have these issues:
- [x] When posting, the last character typed is not saved.
- [x] Can't update a post after editing it - the button remains greyed out.
@SergioEstevao - Changing back and forth from source mode to regular mode should be working fine now. I just applied a fix for the issues you were seeing.
Fixed the remaining issues we'd found. Will keep testing before creating a PR.
Fixed an issue with device rotation by removing an old hack that seems not to be necessary anymore. Ping @bummytime to confirm.
@rachelmcr, @bummytime: Added several fixes for the focusing issues and recovery. Also added a fix for the input accessory view issues when using an iPad.
More specifically:
- The focus should now return after adding images.
- The input accessory view should now be visible when using an iPad.
Due to limitations in WKWebView, we're putting this idea on hold for now.
In particular we're not able to present images from private blogs, as there's no mechanism to add authentication cookies to those requests.
We'll keep this issue open and branch feature/260-wkwebview will be kept updated in case we find a solution for this problem.
More information: https://bugs.webkit.org/show_bug.cgi?id=140191
I'm dissociating myself from this task for the time being, and until cookies-adding support for WKWebView comes out.
Good work on this @diegoreymendez! We will keep our fingers crossed for real cookie support soon...
Just leaving a note that the webkit bug was resolved a couple weeks ago, so hopefully it'll land on iOS 11
WKWebView now has a cookie managing API in iOS 11 😄