3

Problem: Text (Hebrew language) which I set in button shows conversely.

For example:

      NSString *title = @"עמוד הבית"; //This is right-to-left
      UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
      [button setTitle:title forState:UIControlStateNormal];

so: In my simulator i see:

//This is left-to-right

This is left-to-right

How can it fix?

How can I show text correctly?

App supported iOS 6 and iOS 7

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Vit
  • 936
  • 1
  • 10
  • 20
  • What does it mean? Not that that's relevant. Looks like the same thing you typed in just backwards. – PaulG Dec 03 '13 at 19:06
  • 3
    It's being reversed because Hebrew is a right-to-left language. You should be using localized .strings files. – danielbeard Dec 03 '13 at 19:11
  • I might be wrong, but I think that right-to-left languages do not "mirror" each character (as shown in the Simulator output). - Are you sure that the transformation matrix is not modified somewhere? Do Latin characters display correctly? – Martin R Dec 03 '13 at 19:22
  • What's your Xcode version? I tried your code for a button in my project, and it works fine with a system button, but with a custom type, it just doesn't display the text! However I am also an `RTL` developer and I understand how Apple sucks at supporting it. But with the recent versions of SDK it works fine. @MartinR That can happen if the environment really sucks at supporting `RTL`. – Neeku Dec 03 '13 at 19:25
  • Also, does this happen with `UITextLabel`s or `UITextView`s, too? – Neeku Dec 03 '13 at 19:29
  • I solve this problem. – Vit Dec 03 '13 at 19:35
  • 1
    @Vit: Please post your solution (as an answer). – Martin R Dec 03 '13 at 19:37
  • 1
    Sorry it my big bug; I put this button in Scroller but before I have done _scrollView.transform = CGAffineTransformMakeScale(-1, 1); – Vit Dec 03 '13 at 20:01
  • Did you face this issue?please help "http://stackoverflow.com/questions/17955858/hebrew-text-showing-rectangle-in-ios-on-uilabel" – Sanoj Kashyap Dec 21 '13 at 12:26

2 Answers2

2

What worked for me when using an UIButton was this:

if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:button.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft)
{
    button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
}

Links worth reading:

Supporting Right-to-Left Languages (Apple Reference)

AutoLayout + RTL + UILabel text alignment

Community
  • 1
  • 1
inigo333
  • 3,088
  • 1
  • 36
  • 41
0

if you use "#x200F" that will solve your problem,add this as appended string.There is one issue is after adding it all come with and that's weird,if you know the answer.Please, share

Sanoj Kashyap
  • 5,020
  • 4
  • 49
  • 75