Description
Hello.
iOS has RTL mode for apps which makes quite serious difference when the app is supposed to be used in RTL or in LTR mode. The differences are:
- App action-bar would place the back button automatically on the right side of the action-bar, and the arrow would point to right.
- Pages when navigating would slide from left to right (as opposed to right to left for LTR apps).
- Swiping gesture to navigate back starts from the right edge of the screen towards the left (as opposed to starting from left for LTR).
These differences make huge UX issue for RTL apps written in NativeScript when trying to use as much of the native look and feel on iOS.
I made a search on this over the past days, and found some interesting points, such as https://stackoverflow.com/a/42430254, which has a solution that is reported in one way or another across other SO answers and blog posts on the internet. I was able to translate the code to NativeScript with help from @williamjuan027 (thanks!) to this:
// Code is added to an event method to make sure it is running only when the UI is ready
UIView.appearance().semanticContentAttribute = UISemanticContentAttribute.ForceLeftToRight;
UINavigationBar.appearance().semanticContentAttribute = UISemanticContentAttribute.ForceLeftToRight;
const storyboard = new UIStoryboard();
const vc = storyboard.instantiateInitialViewController();
if (vc) {
UIApplication.sharedApplication.keyWindow.rootViewController = vc;
}
However, it is transforming the app into a white screener, meaning it is working, but it is reloading the wrong storyboard/viewcontroller. Next I tried the following to get the current storyboard in order to try it:
const storyboard = UIStoryboard().storyboardWithNameBundle('root', null);
However, I'm unable to figure out the correct combination for the storyboard name and the value for NSBundle
(second parameter).
What am I messing with this and how can I get NativeScript to reload current view-controller in order to get the changes of semanticContentAttribute
get into effect?