Controls change their position

Hi


I have a strange problem with the app.

The problem usually occurs in the first launch of the application through the xcode or after installing the ipa.

The positions of the controls in the app are turned over.

For example: in navigation bar if the back button is always on the left and the menu button on the right then they change positions - the menu button moves to the left side and the back button moves to the right side and so on ...

I use story board with autolayout, the controls contain constraints. The constraints were marked not to be respect to language, so the problem is less evident in the controls themselves.


I tried Google it but found no meaningful information.

I will confirm in advance any answer, help or information.

Replies

May be you have a right to left language ? What is the language you selected ?

In hebrew launguage, but I unmark respect to language in constraints . it means that it doesn't change according the language. no?!

and also it happens in navigation bar.


thanks in advance

no answer ?! 😟

Hold on, I'm not just waiting for the posts !


You should have said to begin with that you had RTL language.


There are several ways:

- in the concerned view :

if #available(iOS 10.0, *) {
     UIView.appearance().semanticContentAttribute = .forceLeftToRight
}

Or look at:

h ttps://stackoverflow.com/questions/31697426/ios-9-disable-support-for-right-to-left-language

first of all - thanks!

I saught this link.

but if i use with this code - it do that all app changes to left to right - may I have a problem if i unmark respect to language ?

all apps that have RTL language - I should do that?

Normally, if you have RTL language, you should accept RTL presentation, including reverse buttons positions, reversed text… That's what user get expecting.


WHy do you want to override this behavior ?

The controls and content of app - is RTL but navigation bar for example : the back icon should be in left and menu icon should be in right and in first launch their positions change. so I want all app is RTL except Navigation Bar.

So I do it like code you brought?


[[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];


thanks in advance


And one more thing:🙂

Why does this happen in the first run and in other launches it's okay?

If it's OK, don't forget to close the thread to keep forum clean.


Wish you good continuation.

Yes I will do it.

Just I should know it's correct what I wrote in previous post .

Is this code?

[[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];


but can it do cause changes about other controls and the navigation side of the screens are opened?


I would appreciate your response

Normally, that should only change the UINavigation bar to LTR.


You will have to check there is no side effect elsewhere.

After checking it affects the entire application because, I think so, UIViewController heir to UINavigation, no?!

It also affects the navigation side of the opening screens.

Is there a possibility to prevent the above?


As mentioned above I uncheck that the constraints will be respect to language direction,

But can I rely on this in a sweeping way for all the controls in the app ?!

Especially since it does not help alongside navigation pages.

UINavigationBar inherits from UIView


The API you call (setSemanticContentAttribute) seems to be for WatchKit.


May be you could simply call (if myBar is the UINavigationBar instance):

myBar.makeTextWritingDirectionLeftToRight(nil)

or

myBar?.makeTextWritingDirectionRightToLeft(nil)

I added this code

[[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];

in AppDelegate in method:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

for all Navigation Bars in app, Isn't right?

like this :

[[UIView appearanceWhenContainedIn:[UIAlertView class], nil] setSemanticContentAttribute:UISemanticContentAttributeUnspecified];

from https://stackoverflow.com/questions/31697426/ios-9-disable-support-for-right-to-left-language (the above link)


and this cause me the above problems..


I dont create inheritance for UINavigationBar , I change this of UINavigationBar of RootViewController.


thanks for your reply