I made an html that references a CSS file, open it in browsers, and the styles are displayed correctly.
Then I load it into the WebView and the styles are not displayed.
I even tried to insert <link> into the DOM from Objective-C, which is my final goal, but it didnβt work.
Should I include CSS in webView somehow?
Editing:
CSS include in html:
<link rel='StyleSheet' href="file://localhost/Users/petruza/Source/Scrapp/build/Debug/Scrapp.app/Contents/Resources/Scrapp.css" type="text/css" >
CSS inserted in the DOM: (I checked and pasted)
NSURL *cssUrl = [[NSBundle mainBundle] URLForResource:@"Scrapp.css" withExtension: nil]; DOMDocument* dom = [[web mainFrame] DOMDocument]; [window setTitleWithRepresentedFilename: lastRunScript]; DOMElement* link = [dom createElement:@"link"]; [link setAttribute:@"rel" value:@"StyleSheet"]; [link setAttribute:@"type" value:@"text/css"]; [link setAttribute:@"href" value: [cssUrl absoluteString]]; DOMElement* head = (DOMElement*) [[dom getElementsByTagName:@"head"] item:0]; DOMElement* headFirstChild = head.firstElementChild; if( headFirstChild ) [head insertBefore:link refChild:(DOMNode *)headFirstChild]; else [head appendChild:(DOMNode *)link];
edit2:
The same html shown in my WebView and in Safari:

source share