Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing WKWebView Accesory bar in Swift

I am trying for a few days now to get this converted into Swift without really having much background with it.

This is what I've got so far ... and I have been looking on google not really knowing what to search for in order to be more specific. Can you please shed some light on what I'm doing wrong ? Thanks

Update:

I have aded the objective-c tag just so more people that are related to this thread may be able to see it and hopefully get an answer.

enter image description here

like image 452
Eduard Avatar asked Nov 22 '15 10:11

Eduard


1 Answers

For those who are still looking, the WebKit team updated WKWebView (iOS 13+) so that you can subclass it to remove/update the input accessory view:

https://trac.webkit.org/changeset/246229/webkit#file1

In Swift, I subclassed it, and returned nil. Worked as expected. I hope it helps.

FYI: I checked the docs, and it doesn't mention not to subclass WKWebView, so subclassing is allowed.

import WebKit

class RichEditorWebView: WKWebView {

    var accessoryView: UIView?

    override var inputAccessoryView: UIView? {
        // remove/replace the default accessory view
        return accessoryView
    }

}

You can find a working version of it here: https://github.com/cbess/RichEditorView/commits/master

like image 194
C. Bess Avatar answered Nov 14 '22 02:11

C. Bess