Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set Accessibility Identifier for UITableView in iOS

Not a big question however I am facing a dilemma. I am implementing some iOS UI Testing and I am unable to set the Accessibility Identifier required for the framework to my UITableView.

That whole section does not seem to be present in the Identity Inspector in interface builder.

Please see screenshot attached.

Evil missing Accesibility section.

I attempted to do it programatically but it did not work as well.

I set the accessibility identifier as enabled and its value in viewDidLoad()

override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view
        // set delegate and data source
        tableView.delegate = self;
        tableView.dataSource = self;

        // load the table Data
        tableData = ["Red", "Green", "Blue", "White", "Yellow"]

        // set accessibility identifier
        tableView.isAccessibilityElement = true
        tableView.accessibilityIdentifier = "tableView"

    }

It is just a sample app where I am testing the actual framework.

Any help is welcome.

I am using XCode 7.3.1

like image 821
user3498133 Avatar asked Aug 03 '16 13:08

user3498133


2 Answers

Try this:

    tableView.accessibilityLabel = "My tableView label"
    tableView.isAccessibilityElement = true

Refer this for more details on accessibility for tableView: Enhance the Accessibility of UITableView

like image 58
Santosh Avatar answered Nov 09 '22 12:11

Santosh


Not identifier, set accessibilityLabel, frameworks use that usually

like image 42
Lu_ Avatar answered Nov 09 '22 12:11

Lu_