UIWebView CSS injection à l'aide de JavaScript

Je suis en train d'injecter un local fichier css dans une UIWebView que la fin du chargement du site web, tels que google, etc.

Je suis en train d'essayer avec du JavaScript, mais sans succès.


- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSString *cssPath = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"styles.css"]];
    NSURL *baseURL = [NSURL fileURLWithPath:cssPath];

    NSString *js = [NSString stringWithFormat:@"var fileref = document.createElement('link');
                    fileref.setAttribute('rel', 'stylesheet');
                    fileref.setAttribute('type', 'text/css');
                    fileref.setAttribute('href', %@);", baseURL];

    [webView stringByEvaluatingJavaScriptFromString:js];
}

Merci,

InformationsquelleAutor | 2011-08-01