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
votes
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 ViewDidLoad
of the my base ViewController class (All of my ViewController classes inherit from this one).