How to set accessibility for programmatic tableView?

1,583 views
Skip to first unread message

Abbey Jackson

unread,
Sep 14, 2015, 5:19:17 PM9/14/15
to KIF iOS Automated Testing Framework
In my project I have a tableView that is created entirely programmatically. I have tried various ways of setting the accessibility label but when I use a breakpoint and po self.tableView.accessibilitylabel I get:

error: property 'accessibilityLabel' not found on object of type 'UITableView *'

error: 1 errors parsing expression


I have tried doing it in viewDidLoad where the rowHeight, color, etc are set. 

I have also tried doing it in initWithStyle where the title of table is set.

I have used only
self.tableView.accessibilitylabel = @"label";

and I have also tried
self.tableView.isAccessibilityElement = YES; 
self.tableView.accessibilitylabel = @"label";

 
Not sure what else to try. Has anyone encountered this problem before?

-Abbey

Michael Lupo

unread,
Sep 14, 2015, 5:31:26 PM9/14/15
to kif-fr...@googlegroups.com
I'm out meeting a friend for a beer, but when I get back on my laptop I'll send you some examples. 

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "KIF iOS Automated Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kif-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abbey Jackson

unread,
Sep 14, 2015, 5:32:45 PM9/14/15
to kif-fr...@googlegroups.com
Thanks, that would be great!

Michael Lupo

unread,
Sep 14, 2015, 7:10:00 PM9/14/15
to kif-fr...@googlegroups.com
I didn't realize I was replying to the KIF discussion list. Doh!

You will need to give the table itself an accessibility identifier.
Either in the storyboard or in code. 
You should also be familiar with NSIndexPath. 
[tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] inTableViewWithAccessibilityIdentifier:@"TableView Tests Table"];

Sent from my iPhone

On Sep 14, 2015, at 5:32 PM, Abbey Jackson <ab...@abbeyjackson.ca> wrote:

Thanks, that would be great!

--

Abbey Jackson

unread,
Sep 14, 2015, 7:12:20 PM9/14/15
to kif-fr...@googlegroups.com
Yes but that is the problem, I can’t figure out how to give it an accessibility label. The methods I’ve seen (see first message) are not working because when I po what the accessibility label is, I get the error "error: property 'accessibilityLabel' not found on object of type 'UITableView *’”

This view controller is 100% programatic so it must be done in code.

Any ideas?

-Abbey

--
You received this message because you are subscribed to a topic in the Google Groups "KIF iOS Automated Testing Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kif-framework/mpdSGe3-73E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kif-framewor...@googlegroups.com.

Michael Lupo

unread,
Sep 14, 2015, 7:25:11 PM9/14/15
to kif-fr...@googlegroups.com
On the UITableView object, in code where the table is constructed...
myTableView.isAccessibilityEnabled=YES;
myTableView.accessibilityIdentifier = @"someTableViewName";

Notice I am using identifier, not label.
In KIF you will use [tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2]  inTableViewWithAccessibilityIdentifier:@"someTableViewName"];

It will work. 

Sent from my iPhone

On Sep 14, 2015, at 7:12 PM, Abbey Jackson <ab...@abbeyjackson.ca> wrote:

Yes but that is the problem, I can’t figure out how to give it an accessibility label. The methods I’ve seen (see first message) are not working because when I po what the accessibility label is, I get the error "error: property 'accessibilityLabel' not found on object of type 'UITableView *’”

This view controller is 100% programatic so it must be done in code.

Any ideas?

-Abbey

On Mon, Sep 14, 2015 at 4:09 PM, 'Michael Lupo' via KIF iOS Automated Testing Framework <kif-fr...@googlegroups.com> wrote:
I didn't realize I was replying to the KIF discussion list. Doh!

You will need to give the table itself an accessibility identifier.
Either in the storyboard or in code. 
You should also be familiar with NSIndexPath. 
[tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] inTableViewWithAccessibilityIdentifier:@"TableView Tests Table"];

Sent from my iPhonemyTableView

Abbey Jackson

unread,
Sep 14, 2015, 7:30:50 PM9/14/15
to kif-fr...@googlegroups.com
Oh!!! I didn’t realize it was identifier and not label. THANK YOU. I’ve been trying to figure this out off and on all day.

-Abbey

kalpesh...@sufalamtech.com

unread,
Jan 20, 2018, 12:30:32 PM1/20/18
to KIF iOS Automated Testing Framework
You can access Tableview Cell for accessing the accesisibility of lable.
Reply all
Reply to author
Forward
0 new messages