4

Our app supports RTL language like Arabic, Persian.

After iOS 9 the navigation controller and tab bar controller behavior has been changed. I found only this link ios-9-disable-support-for-right-to-left-language for solve this problem

I write this code in my appDelegate and it works fine and navigation bar and tab bar set as LTR.

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
    [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
    [[UITabBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}

But my problem is: I can't change interactive pop gesture Direction .

enter image description here

Community
  • 1
  • 1
Mo Farhand
  • 1,144
  • 8
  • 21
  • Why would you want to do this? – Fogmeister Oct 04 '15 at 10:40
  • 1
    @Fogmeister because it's has a bad style and not regular for UX . you can change Language and see Whatsapp ( they have handled this problem ) but telegram team leave this problem. Do u have any idea ? – Mo Farhand Oct 04 '15 at 10:44
  • Is that your opinion or is it something you have spoken to many rtl users about? Where I work we spent a long time interviewing our users. It really is something that rtl users want. – Fogmeister Oct 04 '15 at 10:45
  • @Fogmeister i'm agree with you , but in this case we need this and in Apple Docs you can see this : ~Flipping Cocoa Touch Views and Controls Programmatically` https://developer.apple.com/library/prerelease/ios/documentation/MacOSX/Conceptual/BPInternational/SupportingRight-To-LeftLanguages/SupportingRight-To-LeftLanguages.html – Mo Farhand Oct 04 '15 at 10:49
  • 3
    Mohamad, that doc only describes ways to adapt controls to the new RTL UI in iOS 9, which is the opposite of what you are trying to do here. I would highly recommend not doing this; as more apps start linking against iOS 9, more apps will have the flipped UI by default if they support a RTL language. At the end of the day, it will be your app that will be inconsistent with the rest of the system. – wakachamo Oct 04 '15 at 12:34
  • @wakachamo thanks my Bro for your hint – Mo Farhand Oct 06 '15 at 06:32
  • I have the same issue, I just try to disable it and not find any other solution, if you found out please publish it, http://stackoverflow.com/a/32097310/3477974 – Soheil Novinfard Feb 27 '16 at 09:24
  • @SoheilNovinfard i recommend to you leave this behavior. because it's normal and all of apps in app store accept this behavior :) – Mo Farhand Feb 28 '16 at 09:49

3 Answers3

3

I was struggling with same problem and finally found solution

you just need to set SemanticContentAttribute for navigationController.view

in the rootViewController's viewDidLoad:

[self.navigationController.view setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
[self.navigationController.navigationBar setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
2

In Swift

navigationController?.view.semanticContentAttribute = .forceRightToLeft
navigationController?.navigationBar.semanticContentAttribute =  .forceRightToLeft 
Shoaib
  • 1,295
  • 15
  • 22
0

If your are creating custom pop up, two way you can handle this.

  1. Define a macro in .h file to detect whether it is RTL language or not in runtime.

    define IS_RTL [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft

then create custom layout according if IS_RTL.Like

if (IS_RTL)
//Do Arabic Implementation
else
//Do other language implementation
  1. If you are creating UI from Storyboard, the set constraint to Lead or Trailing space and value of First Item will be Respect Language Direction
Arup Sarker
  • 173
  • 1
  • 9
  • tnx for your answer , but unfortunately after i OS 9 we cant do it without `setSemanticContentAttribute` anyway , `Respect Language Direction` is good for our alignment but for our direction not work. conclusion : we respect to this behavior like many app to app store :) – Mo Farhand Dec 28 '15 at 07:19