ios - 辅助功能:将焦点移至 UITableViewController 中 tableView 的第一个单元格

标签 ios uitableview accessibility navigationcontroller

我有一个主窗口,其中有两个 UITableViewController。在第一个 tableViewController(左 Pane )中选择单元格时,右侧的 tableViewContainer 会被填充。在画外音模式下,我希望当第一个 tableViewController 中的单元格被选中时,secondViewController 中的第一个单元格获得焦点,以便轻弹顺序从那里开始。请注意,我已经尝试过以下两种方法:

1) 制作第二个 View Controller 的第一个单元格,即 firstResponder。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{          
    UITableViewCell *outCell =(UITableCellView*)  [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (indexPath.row == 0)
    {
        [outCell becomeFirstResponder];
    }
}

2) 我还尝试发布布局更改通知,将单元格作为第一个辅助功能项。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{          
    UITableViewCell *outCell =(UITableCellView*)  [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

     if (indexPath.row == 0)
     {
         UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, outCell);
     }
}

以上方法均无效。知道我还能尝试什么或上述方法有什么问题吗?

请注意:我已阅读 View Controller 的文档(https://developer.apple.com/LIBRARY/IOS/#featuredarticles/ViewControllerPGforiPhoneOS/Accessibility/AccessibilityfromtheViewControllersPerspective.html - 将 VoiceOver 光标移动到特定元素)。尝试在我的示例中发布 LayoutChanged 通知和 ScreenChangedNotifications,并尝试使用示例代码(ListAdder - http://developer.apple.com/library/ios/#samplecode/ListAdder/Introduction/Intro.html ,它也像我们一样使用 NavigationController),但以上内容即使在示例中也不起作用。

知道为什么吗?

最佳答案

我通过发布屏幕更改通知 解决了这个问题。该调用的第二个参数是要选择第一个单元格的 TableView 的 View 。

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, [[self nextTableViewController] view];

关于ios - 辅助功能:将焦点移至 UITableViewController 中 tableView 的第一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13377585/

相关文章:

react-native - 通过 AccessibilityManager 的字体大小倍增器

python - Google App Engine (Python) 中的 AES 加密和 iOS (Objective-C) 中的解密

swift - TableView 单元格中的委托(delegate)错误

ios - RxSwift 访问 indexPath.section

html - 强制屏幕阅读器一次阅读一个字母而不是整个单词

html - 如何在 "Alt text"中将文本显示为上标?

ios - 如何使包显示名称长度超过 12 个字符

ios - 无法使用 XCode 7.0 Beta、iOS 8.3 和 aws-ios-sdk-2.2.0 识别 AWSDynamoDB

objective-c - ios 替换 url 中的数据值

objective-c - 当 UITableView 中的每个单元格都是唯一的时该怎么办?