Looking for ios Answers? Try Ask4KnowledgeBase
Looking for ios Keywords? Try Ask4Keywords

iOS Ajout d'un script utilisateur personnalisé chargé à partir du regroupement d'applications


Exemple

let configuration = WKWebViewConfiguration()

if let path = NSBundle.mainBundle().pathForResource("customUserScript", ofType: "js"), 
       source = try? NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String {

        let userScript = WKUserScript(source: source, injectionTime: WKUserScriptInjectionTime.AtDocumentStart, forMainFrameOnly: false)

        let userContentController = WKUserContentController()
        userContentController.addUserScript(userScript)
        configuration.userContentController = userContentController   
    }

let webView = WKWebView(frame: self.view.bounds, configuration: configuration)

Toute valeur dans l'énumération WKUserScriptInjectionTime est valide: .AtDocumentStart , .AtDocumentEnd