adjustable text size in web view interface

When loading the following html string in a uiwebview, I am trying to set the font-size as a variable value:

    NSString * htmlString = [NSString stringWithFormat:@"\
                             <html>\
                             <style type='text/css'>\
                             hr{ height: 0;border-bottom: 2px dotted #000;}\
                             .Prim{color:#000000; direction:ltr;font-size:%d;font-weight:bold;}\
                             .Def_en{direction:ltr;font-size:%d}\
                             .Def_ar{direction:rtl;font-size:%d}\
                             </style>\
                             <table width='100%%'>\<tr>\<td>\
                             <body>\
                             <p style = 'font-size:%dpx;'> %@ <\p>\
                             </td></tr><tr><td><br><br></td></tr><tr><td align ='center'><br><img src='%@' width='60%%' \><br></td></tr></body>\
                             </table>\
                             </html>",textFontSize , authorNAme , cachePath];

This implementation didn't work as expected. What changes should be made to correctly assign the font-size attribute the value of the variable textFontSize?
Appreciate your help.

Answer №1

After some investigation, I managed to identify the issue and it turned out to be quite simple. Here is the snippet of code where the problem lied:

NSString * htmlString = [NSString stringWithFormat:@"\
                         <html>\
                         <style type='text/css'>\
                         hr{ height: 0;border-bottom: 2px dotted #000;}\
                         .Prim{color:#000000; direction:ltr;font-size:%d;font-weight:bold;}\
                         .Def_en{direction:ltr;font-size:%d}\
                         .Def_ar{direction:rtl;font-size:%d}\
                         </style>\
                         <table width='100%%'>\<tr>\<td>\
                         <body>\
                         <p style = 'font-size:%dpx;'> %@ <\p>\
                         </td></tr><tr><td><br><br></td></tr><tr><td align ='center'><br><img src='%@' width='60%%' \><br></td></tr></body>\
                         </table>\
                         </html>",textFontSize+12,textFontSize,textFontSize,textFontSize,authorNAme , cachePath];

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

Multiple instances of the anchor tag are being inserted

Why is the anchor tag I specified in my code appearing multiple times when viewed in the browser? How can I fix this issue? <a href="{{ route('candidate.company.view', $company->id) }}" class="block no-overflow"> <div class="row ...

Incorporate a caret into an element using CSS styling

issue I encountered an issue where <textarea> and Javascript had some quirks when trying to transfer the value into a <pre> tag. My aim was to implement a blinking caret in the <pre> as if I were pressing F7. The reason behind not using ...

Troubleshooting mat-accordion title problem on mobile devices

Despite reading numerous blogs and conducting extensive searches on Google, I am still unable to resolve the CSS issue related to Angular material below. Your assistance in fixing this problem would be greatly appreciated. Desktop view: https://i.stack.im ...

Attempting to iterate through an array of HTML5 videos

Having some trouble with my video array - it plays but doesn't loop. I've tried using the HTML video attribute 'loop' and variations like loop="true" and loop="loop" without success. Tonight, all I want is for it to loop properly! var ...

Do not insert a MUI divider after the final item in the menu

Is there a way to remove the divider after the last category when using MUI components and adding a divider after each category? https://i.sstatic.net/Gx0Zb.png This is my code with the divider right at the bottom before the closing tag. export const ...

Tips on retrieving JavaScript output within an AngularJS model

When I bind the result date to an input text based on the input id, the input value is not saving in the ng model of Angular script. <input type="text" class="form-control" maxlength="10" ng-model="EmployeeSave.HijriDate" onclick="showCal2();" ...

Instructions on designing a three-column layout for six separate div elements

i am having trouble organizing 6 div elements into 3 columns per row. Currently, I have them arranged in two rows, but the issue arises when a column's h2 element is long and it pushes down the column below, creating a large space in the second row. A ...

Disabling a jQuery function on an external page: Step-by-step guide

I have encountered a challenge while trying to load an anchor tag on an external page using a specific method: <a href="page.html#div> This method is meant to link me to another page's particular div. <div name="div"> stuff </> H ...

CSS must be applied to various sections of an HTML document

For example, I have 2 CSS files. In one CSS file, I have the style: a{color: blue;} In the second file, I have: a{color: red;} I want to apply these styles to my HTML file. <div> <a>first file ...

Determining if an HTML dialog was closed using the escape key

Wondering about detecting when an HTML dialog is closed using the ESC key. Specifically referring to the HTML dialog, not jQuery. ...

Troubleshooting: Angular ng-if not correctly detecting empty strings

When looking at my code, I have the following snippet to showcase data from angular scope variables. The initial two lines are functioning correctly and displaying data from the scope variables; however, there seems to be an issue with the line using ng- ...

Unable to play GSM extension files on a web browser due to compatibility issues

I've been attempting to play an audio file with a (.gsm) extension using <audio>, object tags, and JavaScript. <script> var myAudio = new Audio(); // creating the audio object myAudio.src = "test.gsm"; // assigning the audio file t ...

"Bootstrap - creating a dynamic effect with a repeating pattern overlay and vibrant background color in

I'm having trouble adding a repeating background image to my jumbotron that already has a rebecca-purple background color. I've tried multiple approaches, but can't seem to get it right. Here's the code snippet I'm working with: . ...

Retrieve the value from an input field when the value is returned from JavaScript

Scenario: I'm currently working on creating a QR reader to retrieve a specific value. You can check out the progress here: What's functioning: scanning. When I scan a QR code, a value is displayed in the text box. Here's the code snippet b ...

Disable the outer div scrolling in VueJS, but re-enable it once the inner div has reached the bottom of

I am currently working on a webpage that contains multiple divs stacked vertically. Here is the concept I am working with: Once the scrollbar reaches the bottom of the first div, the outer scrollbar will be disabled and the inner scrollbar will be enabled ...

What could be causing the malfunction of this form's submission request?

I'm encountering an issue with a simple login form I have that I want to post to ASP.Net MVC. It seems like when I set the action to /Login, it works perfectly fine. However, if I specify the action name as "/Login/Index", it fails. The server sends b ...

Hidden row in Vuetify's v-row component

My goal is to create a basic 9x9 grid using Vuetify, but unfortunately the last row is not displaying. Interestingly, I can see it in the browser inspector where it should be located, yet it remains hidden. Here's my code: <!-- main.vue --> < ...

Conceal the Slider until Fully Loaded with Slick Slider by Ken Wheeler

I am currently using a slider function called Slick by Ken Wheeler. It is currently being loaded in the footer with just two variables. $('.slickSlider').slick({ dots: true, fade: true }); Currently, ...

Incorporating Entrance Animations for Individual Elements within ngView Using AngularJS

Can each content within ngView be animated individually upon entering, rather than the entire View (div) itself? ...

What is causing Microsoft Edge to highlight this span and behave as though it's a hyperlink?

I am currently in the process of redesigning a website, and I've encountered an issue with the header markup. While the design looks fine on most browsers, it behaves strangely in Microsoft Edge on Windows 10. The phone number in the header is inexpli ...