繁体   English   中英

表格视图不会随着画外音焦点滚动

[英]Table view doesn’t scroll with voiceover focus

我正在使用表格视图,当用户点击特定单元格时,它会展开,并且视图设置如所附图像中所示。

在此处输入图像描述

我的问题与可访问性有关。 当底部的按钮超出屏幕(像 iPhone 6s 这样的小屏幕)时,画外音会聚焦在它们上面,但表格视图不会将它们滚动到视图中。 此外,当我激活(在启用画外音的情况下双击)聚焦按钮时,它们不起作用。 但是当按钮可见时,我可以在启用画外音的情况下激活按钮。 如何让按钮在较小的屏幕上滚动到视图中?

我能够使用 NSNotificationCenter 找到解决此问题的方法。 但是,如果你们有更好的解决方案,请提出建议。

- (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];
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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