2
votes

I came across this issue while I was working on an old app which had localisation for Arabic language which is written RTL. I noticed that in iOS9, my UINavigationController was showing animation right to left when pushing view controllers. My app views were not ready for it. They had been designed for left to right transition even in Arabic storyboard (because previously in older iOS, UINavigationController only supported LTR transition). Now this RTL animation required that I redesign a lot of assets so I wanted to force it to show LTR animation for all languages. After a bit of research I found the solution.

2
This is just for the purpose of sharing because I had not found the topic on SO during my search. I have answered below.Jibran K

2 Answers

4
votes

In iOS9, there is a new constant UISemanticContentAttributeForceLeftToRight for this purpose. The following code fixes the issue and forces left to right animation:

if(([[NSProcessInfo processInfo] respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)]) &&
    [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9, 0, 0}]) {
    [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}

We are checking iOS version first to avoid error in iOS version older than 9. I added the above code in ViewDidLoadof the my base ViewController class (All of my ViewController classes inherit from this one).

1
votes

Since it is only happening on iOS 9 in your app delegate write the following :

if #available(iOS 9.0, *) {
    UIView.appearance().semanticContentAttribute = .ForceLeftToRight
} else {
    // Fallback on earlier versions
};