简体   繁体   中英

Table view doesn’t scroll with voiceover focus

I'm working with a table view and when the user tap on a particular cell it expands and the views are setup as in the attached image.

在此处输入图像描述

My question is related to accessibility. When the buttons at the bottom are out of the screen (small screens like iPhone 6s) voiceover focuses on them but the table view doesn't scroll them into view. Also when I activate (double tap with voiceover enabled) the focused button they don't work. But when the buttons are visible I can activate the button with voiceover enabled. How can I make buttons scroll into view on smaller screens?

I was able to find a workaround for this problem using NSNotificationCenter. But if you guys have a better solution please suggest.

- (void)viewDidLoad {
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(accessibilityElementFocussed:)
                                                 name:UIAccessibilityElementFocusedNotification
                                               object:nil];
    
     //........
}
-(void)accessibilityElementFocussed:(NSNotification*)notification  {
    NSNotification* focusedNotification = notification;
    
    if ([focusedNotification.name isEqualToString:UIAccessibilityElementFocusedNotification])
    {
        NSDictionary* userInfo = focusedNotification.userInfo;
        UIView* view = userInfo[@"UIAccessibilityFocusedElementKey"];
        
        if ([view isKindOfClass:[CustomAttributedUIButton class]])
        {
            CGRect scrollTo = view.superview.superview.superview.superview.frame;
            [self.tableView scrollRectToVisible:scrollTo animated:NO];
        }
    }
}

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