Problem in rendering Hebrew text in UIWebview - iphone

I have some hebrew text stored in database. When I fetch & render it in UIWebview after applying some css (setting the background color and margin for the page) the text comes up fine but the problem is that If I right align the content in webview then the Hebrew content gets right aligned but actually it is not the way it is supposed to be. I mean the way RTL text should have shown. The Full stop appears on the right hand side of the text as shown in image below. I know that right aligning the text will not show it the way RTL text should be
Its not a duplicate and I have gone through the steps mentioned there but still no go.
I hope if someone can help me to shown the text in correct way . I can add the CSS snippet if required. Please comment if any supporting code or image is required

You should either set direction: rtl in the CSS or add a dir="rtl" attribute in the HTML.
You may also need to fiddle with the unicode-bidi CSS attribute as well if you're embedding this text into a mixed-language paragraph.

u need to specify dir="rtl" in html then you will get the data from right to left
Example:
NSString *htmlStringwithFont = [NSString stringWithFormat:#"<span style=\"font-family: %#; color:#343434;font-size: %i\" **dir=\"rtl\"**>%#</span>",
font.fontName,
(int) font.pointSize,
content];
webView.opaque=NO;
[webView loadHTMLString:htmlStringwithFont baseURL:nil];

Related

Add line breaks when displaying a long string in UIWebView

When displaying a paragraph with some long strings without line breaks in an UIWebView, the size of the character is too small for reading, as show in the following pic. Is there anyway to automatically add line breaks in the long strings as in the UILabel? Thanks in advance!
ps. the UIWebView is used to display an email body.
set the css as : style="word-break:break-all" to solve this problem
Simply NO. UIWebView is made to parse HTML-Markup. The breaking has to be done there. \n will do it.
Other than that, you should rethink your HTML-Box-Model being responsive.
If you only want to display text, then use UITextView instead of UIWebView and switch to UIWebView, if its HTML. I think Mail.app on iOS does it like that. UITextView text is appropriately scaled.

Custom Font in Text View/Interface Builder

I hope this is a really simple question, but it's stumped me. Basically, I have a huge amount of text that I'm using the text view for. For the most part, it's just the system font. However, I would like to format "headers" every few paragraphs in the large chunk of text with a custom font (that I've added to my project) and background color. How do I target small pieces of text within the text view?
If it were just a small piece of text, I would just add a label and do it with code, but since this a huge piece of text, what's the best way to do it?
Thanks!
If you load a large amount of static text with formatting, I suggest you save it as a html file and load it into UIWebView.

printing text as a paragraph(indentation) in uitextview in iphone

A basic functionality I am trying to implement in UITextView.
I have a text (NSString) and I am trying to place in to the text field as a paragraph (indentation). Is it possible? I have seen many links but none of them have an exact answer.
We have a property named textAlignment but it is for left, right or center not indention.
Can anyone suggest how to implement this?
You should consider using a UIWebView if your displayed text has formatting. Using textViews and labels quickly renders the code to complex.
Possible solution in this post - as the first answer suggested, use a UIWebView.

Cocoa Touch text view with aligned, justified text

I am trying to create a textview with predefined height that will contain justified text.
When entering the text into the view, I need to be able to check when the view is full.
How would I do this? Core Text?
I am using sdk-3.2.
You cannot do it using UITextView (that would be the most "logical" way to do it), or any others SDK current classes.
The only simple way to do it if to put the content to be justified in an html file, justify it using CSS, and show it in a UIWebView.

Why would a link in a UIWebView leave a gray box behind?

I have a UIWebview that I am loading with custom HTML using loadHtmlString. My HTML has a link that I intercept when tapped so that I can take control and reload the UIWebview with a different HTML string. The code works, but the area where the link text was located is replaced with a gray rectangle that is visible when the new string is loaded.
What could be going on here? How can I get rid of this behavior?
//Scott
Here it is...need to add this style statement to the link reference:
<a href=http://yourlink.com/ style = "-webkit-tap-highlight-color:rgba(0,0,0,0);">
Setting the alpha value (the last parameter to rgba) to 0 disables the tap highlight color.
Although this works, it feels like a hack. I really think the tap highlight should clear itself when my second loadHtmlString reloads new HTML code.
//Scott
You could add onclick="this.blur(); location.href=this.href;" to the link to remove the focus from the link.
I'm sure there's a better less hackish way, but this should work