HTML5 Embedding in WebView (CSS issues)

Xcode 5: Embedding HTML Files in iOS App I have HTML files (along with CSS files) in my iOS app that I embed using the following code:

[webviewRevistas loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];

While this code works fine, it does not seem to load the CSS file, resulting in a lack of style.

It's worth noting that the structure is correct, as opening the files in a browser shows them working properly.

Answer №1

Perhaps you need to specify the base URL in this manner?

[theWebView loadHTMLString:htmlString baseURL: INSERT_BASE_URL_HERE];

The official documentation outlines it as follows:

 - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL

Arguments

[string] The content for the main page.

[baseURL] The base URL for the content.

Reference: UIWebView in Apple iOS Developer Library

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling with implementing responsive mobile buttons that stack in a column? Here's the solution

My content is nearly responsive on all screen sizes, but I'm having trouble getting the buttons to stack neatly in a column. Can anyone provide suggestions on how to fix this issue? You can view the current progress below. Thank you in advance for any ...

The CSS selector for adjacent siblings seems to be malfunctioning

This code is designed to show the "container-1" division every time I hover over the "container" division. However, it's not behaving as expected because instead of displaying block on hover, it simply remains hidden. CSS Code .container:hover + .con ...

Having difficulty with collapsing Bootstrap side navigation menu levels

I've been searching high and low for an example that matches my current issue, but so far, no luck. I'm attempting to design a collapsible side navigation with multiple levels in bootstrap using bootstrap.js. The problem I'm facing is that ...

Limit the number of cells displayed in the tableView and dynamically load more cells as the user scrolls to the last cell

Currently, I am working on setting up a table view that displays a specific number of cells at a time. The idea is for only two cells to be shown initially, with more cells appearing as the user scrolls down the screen. To achieve this, I fetch all JSON da ...

jQuery: Maintain hover state regardless of browser's suggestions for input elements

I have a navigation with a nested ul list structure like this <ul id='mainNav'> <li> Some Stuff! <ul> <li>Page 1</li> <li>Page 2</li> </ul> </li> <li> Hover here t ...

Learning the process of extracting Fast Fourier Transform (FFT) data from an audio tag within

I am struggling to retrieve the FFT data from an <audio> tag without any syntax errors. After reviewing the Web Audio API documentation, I have written a sample code snippet as follows: <audio id="aud" controls="controls" src="test.mp3"></a ...

Unlock the secret to populating a Dictionary with values in Swift

Creating a Dictionary in Swift with various types of data (arrays, strings, dictionaries) can be challenging. I am able to insert new data into a key, but adding more values to them proves to be difficult. Below is the JSON representation of the dictionary ...

Hover Effect: Inner Border Style Applied to Image Using CSS

I've been on the hunt for a straightforward hover effect to use on images in a gallery. I'm looking for something simple that will add a slight 10px width, 40% transparency to the images. While many tutorials show how to achieve this effect on a ...

Error during compilation due to a missing parenthesis in the loop structure

I've been experimenting with creating a carousel using just html and css, without any Javascript. I've been exploring resources on the web and following tutorials to achieve this goal. However, I've encountered an issue. I created a mixin l ...

Using jQuery to dynamically insert an HTML element into a table

I'm trying to insert a hyperlink into an empty HTML table. This function works perfectly fine on Firefox and Chrome, taking only 0.2 seconds to load. However, when I try it on IE9, it takes at least 3 minutes to display the link. The issue seems to be ...

Tips for utilizing StoryBoard references in UITableView or UICollectionView

In my app, I have a table view where each cell opens up a unique flow of view controllers when clicked. Although Xcode 7 introduced storyboard references for linking flows in different storyboards, I'm unsure if this feature can be used for UITablevi ...

Rearrange the li elements within multiple ul lists using JavaScript

Is there a way to reorder multiple ul-lists on my website using JavaScript? An example of the lists may be as follows: $(document).ready(function() { var ul = $('ul.filelist'); for (let u = 0; u < ul.length; u++) { const element = ul[ ...

I noticed an excess of white space on the right side of my Angular website

Check out my website here. Everything seems to be functioning correctly, however, there is an issue with scrolling on mobile. It should only scroll up and down, not left and right! I have noticed a strange white space on the right side of my site when view ...

Text with buttons displayed using a UILabel

Can UILabels or UITextViews be combined with UIButtons? For instance: "The Cup on the table is red and made of glass." In this scenario, Cup represents the UIButton which can appear at any position within the sentence. ...

Injecting HTML with jQuery and AJAX and Implementing Gallery Plugins

In my exploration of jQuery and loading HTML from external files, I've encountered a problem. My goal is to extract a URL parameter, use it to load a file named data.html where the data represents the parameter value for gallery, inject the content of ...

Utilizing the UINavigationController in conjunction with UIViewControllers featuring a see-through background

When using a UINavigationController, the default behavior involves slowly moving the currentViewController to the left and the newly pushed view controller slightly faster. This effect is effective with a solid background. However, when I attempt to use a ...

CSS 4.0 Validation Error: The property name "-webkit-text-decoration" is unrecognized in this context

After completing the Udemy course The Complete ASP.NET MVC 5 Course, I encountered an issue with Bootstrap. Despite having the latest versions of Bootstrap, jQuery, and popper.js installed, the functionality simply did not work as expected on my project. I ...

The footer element rebels against its designated functionality

The standard structure follows: <body> <div class="wrapper"> <nav></nav> <myContent></myContent> </div> </body> <footer></footer> In this setup, the footer is expected to ...

iOS 8 has an issue with the animation of text fields

Previously, this code worked flawlessly on iOS 7. However, after updating to iOS 8 and Xcode 6.0.1, it seems to have stopped functioning correctly. The intended behavior was for a text field to animate and float just above the keyboard when clicked, allo ...

Utilize jQuery to automatically link URLs in order to enhance the appearance of user-generated content

Is it possible to generate anchor elements dynamically within any text containing a URL? For example: Transform this <p>go to http://google.com</p> Into this <p>go to <a href="http://google.com">link</a></p> ...