Skip to content

Commit

Permalink
Merge pull request #419 from yakubbaev/master
Browse files Browse the repository at this point in the history
Fixed UILabel accessibility - set accessibility value after setting text
  • Loading branch information
nicklockwood committed Oct 26, 2015
2 parents 72ff019 + 6135288 commit cb7f3ce
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions FXForms/FXForms.m
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,9 @@ @implementation FXFormDefaultCell
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.detailTextLabel.text = [self.field fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;

if ([self.field.type isEqualToString:FXFormFieldTypeLabel])
{
Expand All @@ -2705,6 +2707,7 @@ - (void)update
else if ([self.field.type isEqualToString:FXFormFieldTypeBoolean] || [self.field.type isEqualToString:FXFormFieldTypeOption])
{
self.detailTextLabel.text = nil;
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;
self.accessoryType = [self.field.value boolValue]? UITableViewCellAccessoryCheckmark: UITableViewCellAccessoryNone;
}
else if (self.field.action)
Expand Down Expand Up @@ -2901,6 +2904,7 @@ - (void)layoutSubviews
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.textField.placeholder = [self.field.placeholder fieldDescription];
self.textField.text = [self.field fieldDescription];

Expand Down Expand Up @@ -3110,8 +3114,10 @@ - (void)layoutSubviews
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.textView.text = [self.field fieldDescription];
self.detailTextLabel.text = self.field.placeholder;
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;
self.detailTextLabel.hidden = ([self.textView.text length] > 0);

self.textView.returnKeyType = UIReturnKeyDefault;
Expand Down Expand Up @@ -3227,6 +3233,7 @@ - (void)setUp
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.switchControl.on = [self.field.value boolValue];
}

Expand Down Expand Up @@ -3266,7 +3273,9 @@ - (void)setUp
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.detailTextLabel.text = [self.field fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;
self.stepper.value = [self.field.value doubleValue];
}

Expand All @@ -3279,6 +3288,7 @@ - (void)valueChanged
{
self.field.value = @(self.stepper.value);
self.detailTextLabel.text = [self.field fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;
[self setNeedsLayout];

if (self.field.action) self.field.action(self);
Expand Down Expand Up @@ -3319,6 +3329,7 @@ - (void)layoutSubviews
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.slider.value = [self.field.value doubleValue];
}

Expand Down Expand Up @@ -3350,7 +3361,9 @@ - (void)setUp
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.detailTextLabel.text = [self.field fieldDescription] ?: [self.field.placeholder fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;

if ([self.field.type isEqualToString:FXFormFieldTypeDate])
{
Expand Down Expand Up @@ -3382,6 +3395,7 @@ - (void)valueChanged
{
self.field.value = self.datePicker.date;
self.detailTextLabel.text = [self.field fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;
[self setNeedsLayout];

if (self.field.action) self.field.action(self);
Expand Down Expand Up @@ -3443,6 +3457,7 @@ - (void)layoutSubviews
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.imagePickerView.image = [self imageValue];
[self setNeedsLayout];
}
Expand Down Expand Up @@ -3582,7 +3597,9 @@ - (void)dealloc
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;
self.detailTextLabel.text = [self.field fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;

NSUInteger index = self.field.value? [self.field.options indexOfObject:self.field.value]: NSNotFound;
if (self.field.placeholder)
Expand Down Expand Up @@ -3637,6 +3654,7 @@ - (void)pickerView:(__unused UIPickerView *)pickerView didSelectRow:(NSInteger)r
{
[self.field setOptionSelected:YES atIndex:row];
self.detailTextLabel.text = [self.field fieldDescription] ?: [self.field.placeholder fieldDescription];
self.detailTextLabel.accessibilityValue = self.detailTextLabel.text;

[self setNeedsLayout];

Expand Down Expand Up @@ -3678,6 +3696,7 @@ - (void)layoutSubviews
- (void)update
{
self.textLabel.text = self.field.title;
self.textLabel.accessibilityValue = self.textLabel.text;

[self.segmentedControl removeAllSegments];
for (NSUInteger i = 0; i < [self.field optionCount]; i++)
Expand Down

0 comments on commit cb7f3ce

Please sign in to comment.