8

The screen is in the Arabic language and it's semantic is set right to left. The whole screen consists of a table view with customs cells. I need to change the semantics of one of the cells in the table view to left to right. The cell has two text fields side by side

I have tried cell.countryCodeField.semanticContentAttribute = .forceLeftToRight which is not working

my custom cell

class EditmobileNumberCell: UITableViewCell {

    @IBOutlet weak var mobileNumberField: UITextField!
    @IBOutlet weak var countryCodeField: UITextField!
    @IBOutlet weak var hintLabel: UILabel!
    @IBOutlet weak var mobileNoPlaceHolder: UILabel!
    @IBOutlet weak var backView: UIView!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
            countryCodeField.addRightImage(image: #imageLiteral(resourceName: "icMobileDropdown"), contMode: .bottom)

        mobileNumberField.textAlignment = .left
        countryCodeField.textAlignment = .left
        hintLabel.textAlignment = .left
        mobileNoPlaceHolder.textAlignment = .left
        mobileNumberField.semanticContentAttribute = .forceLeftToRight
        countryCodeField.semanticContentAttribute = .forceLeftToRight
        hintLabel.semanticContentAttribute = .forceLeftToRight
        mobileNoPlaceHolder.semanticContentAttribute = .forceLeftToRight
    }

Any help will be appreciated. Thanks in advance.

bestiosdeveloper
  • 2,339
  • 1
  • 11
  • 28
Aditya Ahuja
  • 316
  • 3
  • 17
  • 1
    just take view in cell and all controllers place in side the view and make view semanticContentAttribute to forceLeftToRight – Sagar Bhut Sep 03 '19 at 11:06

4 Answers4

5

Create a view inside the cell and add all the controllers inside it and then use view semanticContentAttribute to forceLeftToRight, in the above case write inside awakeFromNib() -

backView.semanticContentAttribute = .forceLeftToRight

This worked for me

Aditya Ahuja
  • 316
  • 3
  • 17
4

You need to change semanticContentAttribute for the tableView, changing the cell semanticContentAttribute won't do any change.

tableView.semanticContentAttribute = .forceLeftToRight

That should get the job done.

AaoIi
  • 8,288
  • 6
  • 45
  • 87
1

Try cell.contentView.semanticContentAttribute = .forceLeftToRight

J. Doe
  • 12,159
  • 9
  • 60
  • 114
-1

Just uncheck your 'Respect language direction' from your leading/trailing constraints in storyboard. then your semantic thing will work for that specific cell:

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129