How to change UIActivityController view to forceRightToLeft always - ios

UIActivityController view is not supporting rtl. I have set UIView.appearance().semanticContentAttribute = .forceRightToLeft in AppDelegate. If device language is English ActivityController is still opening in leftToRight instead of RightToLeft.
It is working fine with device language is Arabic.
Even I have tried to make activity controller view to rightToleft but no luck.
Should be rightToLeft.

You need to add languages in localisation section under info section in Xcode.
for more details checkout this link
output:

Related

Wrong Chromecast buttons position with RTL (right-to-left)

I am using googlecast example.
When I show GCKUIExpandedMediaControlsViewController, all the buttons are in the correct position.
But when I use this part of the code, the buttons overlap each other.
UIView.appearance().semanticContentAttribute = .forceRightToLeft
I don't know if this is important, but the language in the iPhone settings - English.
This is the result that I get
We don't support RTL well now. You can file a feature request here https://developers.google.com/cast/support

UI hangs after changing semanticContentAttribute

I have an application with two languages: Arabic & English. I would like to change UI direction after changing the language inside the app.
I use this code to do this:
UIView.appearance().semanticContentAttribute = isRTL ? .forceRightToLeft : .forceLeftToRight
This code is working well, I will get UI with the correct direction, but the app performance is going worse. I have some lagging while selecting tabs on my Tab View Controller.
Any ideas on how to fix it? (removing changing semanticContentAttribute fix this problem, but I have to use this code for supporting Arabic language)

Localization in Arabic

I am currently working on Localization. I have my app in English and Arabic. When I change the Language to Arabic all object goes to right, but there are few objects that i want them to be in left. Could please tell how to disable that function on a specific object?
Try setting the semanticContentAttribute property for the particular view to forceLeftToRight
someView.semanticContentAttribute = .forceLeftToRight
You can find more about it semanticContentAttribute in apple docs

Possible to hide a button on particular language in iOS with base localization?

I'm new to localization. I've got my app mostly converted, but I have a case where a button only appears in the US English version of the app, but no other languages. Is this possible using main.strings and localizable.strings?
Jakub Vano's answer is pretty useful, but also you can set that string with a special value as "notToShow" and do this
if ([NSLocalizedString(#"MyString", nil) isEqual:#"notToShow"]){
//hide button
}
If we are talking code, you can check current locale via
[[NSLocale currentLocale] localeIdentifier]
and show / hide button accordingly. If you are using storyboard / xib, you can have separate interface for each localization.

Creating Right to Left user interface for iOS

As per apple documentation
"iOS doesn’t automatically mirror controls, so if you want this behaviour for an iOS app, subclass the control and override the drawing methods."
I want to mirror my whole UI when the user selects the language as Arabic or hebrew in the home screen. i was searching for tutorials and documentation for the same but nothing helps.
Please find what i have done till now:
am using Xcode 6.1 and the app targets from iOS 7 to iOS 8.1.
Autolayout is enabled and am not using left or right constraints. am using only leading or trailing constraints.
Base internationalisation is enabled in project settings also have added the languages in localization. but when am running the app in device and set device language and region to arabic i cant get the mirrored UI. Do i have to do anything in code to get the mirrored UI?
What is the best way to support RTL based UI? How to subclass control and override drawing methods?
Please use this link to get the sample screenshot of my app.
I just found a easy way from Apple documentations instead of having 2 storyboards for RTL and LTR languages.
First of all enable Base internationalisation in project settings
Add your language - in my case i have added arabic and hebrew
xCode will localize your stroy boards and you can see different storyboard strings for different languages
Change the texts for your labels in the newly created strings file. In my case i changed in arabic and hebrew string files
Use AutoLayout for designing the whole UI.
Don't use Left or right constraints. Instead of use only leading and trailing constraints
Add the below code in your main function and run the app in simulator
NSArray* languages = [NSArray arrayWithObjects:#"ar", nil];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:#"AppleLanguages"];
Your app now will work for RTL language with mirrored UI without having 2 storyboards.
Note : if you are not setting the autolayout constraints correctly it wont work. However because of the new screens you have to learn to use auto layout.
in Swift
let languages = ["ar"]
UserDefaults.standard.set(languages, forKey: "AppleLanguages")

Resources