簡體   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