我是 iOS 新手。我正在制作包含语音功能的应用程序。我的应用程序包含来自表格 View 的 Collection View 。该应用程序有复选框(??没有按钮只是图像)并且显示选中/未选中状态。
当我选中复选框然后旁白阅读此内容时。 -> [self.checkBoxImageView setAccessibilityHint:@"~~~~"];
第一次尝试时操作正确(语音朗读),但第二次后语音朗读反转。
如何修改以修复我想要操作的代码。
在下面附上我的代码。
=========================第一个函数=================== ======
- (void)setChecked:(BOOL)checked {
NSLog(@"%s, checked = %d", __func__, _checked);
NSLog(@"[D] checked : %d", checked);
// Save property value
_checked = checked;
// Update checkbox image
NSString * filename;
if(checked)
{
filename = [[NSBundle bundleForClass:[self class]] pathForResource:@"check_on" ofType:@"png"];
[self.checkBoxImageView setAccessibilityHint:@"Checked"];
}
else
{
filename = [[NSBundle bundleForClass:[self class]] pathForResource:@"check_off" ofType:@"png"];
[self.checkBoxImageView setAccessibilityHint:@"Unchecked"];
}
[self.checkBoxImageView setImage:[UIImage imageWithContentsOfFile:filename]];
NSLog(@"[D] self.checkBoxImageView setImage:[UIImage");
self.checkBoxImageView.frame = CGRectMake(12, 12, 50/2, 50/2);
NSLog(@"[D] self.checkBoxImageView.frame = CGRectMake");
}
=========================另一个函数==================== =====
- (void) collectionView:(UICollectionView *)cv didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%s", __func__);
NSLog(@"%@", indexPath.description);
//[collectionView deselectItemAtIndexPath:indexPath animated:YES];
//// Get selected cell
//MYCell* cell = (MYCell*) [collectionView cellForItemAtIndexPath:indexPath];
[cv deselectItemAtIndexPath:indexPath animated:NO];
// Get selected cell
MYCell* cell = (MYCell*) [cv cellForItemAtIndexPath:indexPath];
// if (cell.checked == NO)
// cell.checked = YES;
// else if (cell.checked == YES)
// cell.checked = NO;
// Check if set contains selected cell indexPath
if([self.checkedIndexPaths member:indexPath])
{
// User tapped on checked cell
// Remove selected indexPath from set
[self.checkedIndexPaths removeObject:indexPath];
// Uncheck checkbox on cell
cell.checked = NO;
}
else // User tapped on unchecked cell
{
// Add selected indexPath to set
[self.checkedIndexPaths addObject:indexPath];
// Check checkbox on cell
cell.checked = YES;
}
}
最佳答案
辅助功能提示旨在提供有关元素功能的额外信息。因此,画外音系统假定内容大部分将保持静态(除非页面布局发生变化)。另请注意,许多用户即使在画外音模式打开时也将其关闭。
在这种情况下您应该设置的属性是 accessibilityValue
( Apple doc )。这用于元素中的动态内容,例如 UITextField 中的文本。
关于ios - 是否有获得延迟焦点状态的 api 语音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45115612/