Reputation: 1031
I am trying to create a simple WebView app using UITabBarViewController. The CSS does not load when I use Tab Bar. If I use a simple View Controller, the CSS loads. There are no other changes to the code.
let request: NSMutableURLRequest = NSMutableURLRequest(url: myUrl)
if (webView != nil) {
} else {
self.loadView()
self.webView.navigationDelegate = self
}
if (self.finishedUrl != myUrl.absoluteString) {
webView.load(request as URLRequest)
}
Upvotes: 0
Views: 4773
Reputation: 1
I had the same issue and resolved it by adding the resources as "Create folder instance" instead of "Create groups".
Create groups indexes the file but strips it of its path. Calling the file is done by calling the filename (unique filename is important in the group). Create folder instance maintains the folder structure
Cfr. Create groups vs Create folder reference in Xcode
Upvotes: 0
Reputation: 178
I've got the same problem but nothing here helped me. The solution was to remove the folder path in the link, even if they were inside these folders in my Bundle.
Instead of having this:
<link rel="stylesheet" href="css/style.css" />
Removed the folder part and left this:
<link rel="stylesheet" href="style.css" />
And it worked. The same happened with the .js file
Upvotes: 1
Reputation: 1452
I had the same problem. My styles.css file was being referenced in the .HTML files just file, and it worked great loading up directly in a browser.
The problem that I had was that my styles.css wasn't included in any of my Targets. After I checked the box, it loaded up great.
Upvotes: 0
Reputation: 1031
So, I was able to solve the problem and the problem was /
. If you put /
to the end of url, CSS doesn't load. But, if you don't put /
to the end, CSS gets loaded.
Upvotes: 2
Reputation: 3256
Replace your if
condition, it doesn't make sense to perform actions on a nil
webview
.
if (webView != nil) {
} else {
self.loadView()
self.webView.navigationDelegate = self
}
if (self.finishedUrl != myUrl.absoluteString) {
webView.load(request as URLRequest)
}
should be:
if (webView != nil) {
self.loadView()
self.webView.navigationDelegate = self
}
if (self.finishedUrl != myUrl.absoluteString) {
webView.load(request as URLRequest) // also make sure this is being executed.
}
Upvotes: 0