0

My app supports both English and Arabic. If I change the system language from English to Arabic, the layout automatically becomes right-to-left.

However, I want to add a feature that users can change language from inside my app. Apparently, the layout will remain the same if I just reload the bundle. I googled this and people suggest that after changing language to Arabic I should call

[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;

But this doesn't work perfectly. In my case, when I push a view controller that contains a table view, the first few lines still remain left-to-right. I have to scroll down a bit to move these cells offscreen, and then scroll them back. At this time they will become right-to-left.

Does anyone know how to fix this?

P. Tsin
  • 435
  • 4
  • 14

1 Answers1

2

This is because your tableview cells is being dequeued, you have to reload the tableview after this line:

[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
[self.tableview reloadData];
Harjot Singh
  • 535
  • 7
  • 24
  • I set the semanticContentAttribute property from application:didFinishLaunchingWithOptions: in AppDelegate.m, and that table view controller is not the root view controller. I click a button in the root view controller, then the one that contains the table view is pushed in. – P. Tsin Mar 01 '19 at 01:39