简体   繁体   中英

Accessibility: Moving voice over focus to the first cell in tableView in UITableViewController

I have a main window which has two UITableViewControllers. On selecting the cell in first tableViewController (left pane), the tableViewContainer on the rightside gets populated. In the Voice over mode, I want that when the cell in the first tableViewController is selected, the first cell in the secondViewController gets focus so that the flick order starts from there. Please note that I have already tried the following two approaches:

1) Making the first cell of the second view controller, the firstResponder.

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

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

2) I also tried posting the layout changed notification given the cell as the first accessibility item.

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

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

None of the above approaches worked. Any idea what else can I try or what is wrong with the above approaches?

Please note that: I have read the View controller's documentation ( https://developer.apple.com/LIBRARY/IOS/#featuredarticles/ViewControllerPGforiPhoneOS/Accessibility/AccessibilityfromtheViewControllersPerspective.html - Moving the VoiceOver Cursor to a Specific Element). Tried posting LayoutChanged notifications as well as ScreenChangedNotifications in my sample as well as tried with the sample code (ListAdder - http://developer.apple.com/library/ios/#samplecode/ListAdder/Introduction/Intro.html , which also uses the NavigationController as we does), but the above did not work even with the sample.

Any idea why?

I solved this issue by posting the screen changed notification . The second parameter to that call is the table view's view that you want to select the first cell of.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM