fix bug for tabbar

This commit is contained in:
panxi 2019-05-02 16:34:21 -04:00
parent 2fdd88356b
commit f8ec75c7d5

View File

@ -193,7 +193,7 @@ static NSString * const COLLECTION_CELL_ID = @"cell";
[label layoutIfNeeded];
label.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
[self setCellAccessibility:cell title:label.text isSelected:NO];
[self setCellAccessibility:cell title:label.text isSelected:NO indexPath:indexPath];
if (indexPath.row == self.selectedIndex) {
label.textColor = [UIColor mfTomatoRed];
@ -403,19 +403,19 @@ static NSString * const COLLECTION_CELL_ID = @"cell";
[self.delegate topTabbar:self didSelectItemAtIndex:indexPath.row];
}
[self setCellAccessibility:cell title:label.text isSelected:YES];
[self setCellAccessibility:cell title:label.text isSelected:YES indexPath:indexPath];
}
- (void)reloadData {
[self.collectionView reloadData];
}
- (void)setCellAccessibility:(UICollectionViewCell *)cell title:(NSString *)title isSelected:(BOOL)isSelected {
- (void)setCellAccessibility:(UICollectionViewCell *)cell title:(NSString *)title isSelected:(BOOL)isSelected indexPath:(NSIndexPath *)indexPath {
cell.isAccessibilityElement = NO;
cell.contentView.isAccessibilityElement = YES;
NSString *accKey = isSelected ? @"toptabbar_tab_selected" : @"AccTab";
NSString *accLabel = [title stringByAppendingString:[MVMCoreUIUtility hardcodedStringWithKey:accKey]];
NSString *accString = [accLabel stringByAppendingString:[NSString stringWithFormat:[MVMCoreUIUtility hardcodedStringWithKey:@"AccTabIndex"], self.selectedIndex + 1, [self.datasource numberOfTopTabbarItems:self]]];
NSString *accString = [accLabel stringByAppendingString:[NSString stringWithFormat:[MVMCoreUIUtility hardcodedStringWithKey:@"AccTabIndex"], indexPath.row + 1, [self.datasource numberOfTopTabbarItems:self]]];
cell.contentView.accessibilityLabel = accString;
NSString *accHint = isSelected ? nil : [MVMCoreUIUtility hardcodedStringWithKey:@"AccTabHint"];
[cell.contentView setAccessibilityHint:accHint];