3

Is there anyway to set an accessibilityLabel for the title of UIViewController? The title of view controller is a string, and I'm sure for the title there should be a label somewhere, just how do I access it? Could one of the navigation items be the title?

Thanks!

Edit: Yes the reason for asking is that I need different accessibilityLabel for the title.

Heuristic
  • 5,087
  • 9
  • 54
  • 94

2 Answers2

1

You can usetitleView

For example you can put the code in the viewDidLoad method

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
label.text = self.title;
label.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = label;

then you can change the label.text by changing the title of the view controller

Wilson XJ
  • 1,750
  • 13
  • 14
1

Use the accessibilityLabel property of self.

For example, you can put this in the viewDidLoad method.

self.accessibilityLabel = @"Label for accessibility";
Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70