4

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

1)制作第二个视图控制器的第一个单元格,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);
     }
}

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

请注意:我已阅读视图控制器的文档(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 就像我们所做的那样),但即使使用示例,上述内容也不起作用。

知道为什么吗?

4

1 回答 1

0

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

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

于 2016-08-30T22:30:41.723 回答