简体   繁体   English

关闭表格视图中单元格的画外音焦点,而不是其他单元格

[英]Turning off Voice-over focus for a cell in table view and not for others

The first cell in my table view is a dummy cell and thus, when Voice-over mode is ON, I want to skip that cell so that the focus does not come to that control and thus, none of its traits are spoken by the Voice over.我的表格视图中的第一个单元格是一个虚拟单元格,因此,当画外音模式打开时,我想跳过该单元格,以便焦点不会落在该控件上,因此,语音不会说出它的任何特征超过。 I wrote the code pasted below to acheive the same, thinking that isAccessibilityElement alone is sufficient for this.我写了下面粘贴的代码来实现相同的目的,认为仅isAccessibilityElement就足够了。 But it seems that is not the case.但似乎并非如此。 Even though this element i said to be non-accessible in the code, still its getting focus by right/left flicks in Voice-over mode.尽管我说这个元素在代码中是不可访问的,但它仍然通过在Voice-over模式下向右/向左轻弹来获得焦点。 Any idea as to how this can be achieved?关于如何实现这一点的任何想法?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
....
     UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
     if(indexPath.row == 0)
     {
          cell.isAccessibilityElement = 0;
     }
}

use some cutom cell, and within that cell definition implement this:使用一些 cutom 单元格,并在该单元格定义中实现:

- (NSInteger)accessibilityElementCount {
    NSIndexPath *indexPath = [(UITableView *)self.superview indexPathForCell: self];
    if(indexPath.row==0){
        return 0;
    }
    else{
        return 1;
    }
}

The current way to do this seems to be setting accessibilityElementsHidden on the cell to true / YES (depending on whether using Swift or Obj-C.当前执行此操作的方法似乎是将单元格上的accessibilityElementsHidden设置为true / YES (取决于是使用 Swift 还是 Obj-C。

Seems cleaner than other answers proposed and seems effective in my very brief testing.似乎比提出的其他答案更清晰,并且在我非常简短的测试中似乎很有效。

Just override the cell's function accessibilityElementCount like this:只需像这样覆盖单元格的功能accessibilityElementCount

Swift 4.2:斯威夫特 4.2:

override func accessibilityElementCount() -> Int {
   return 0
}

It's not ideal but could you only display the cell when VoiceOver is not activated?这并不理想,但您能否仅在 VoiceOver 未激活时显示单元格? You can use the您可以使用

UIAccessibilityIsVoiceOverRunning()

Function to see if VoiceOver is on when your app loads, and register the在您的应用程序加载时查看 VoiceOver 是否打开的功能,并注册

@selector(voiceOverStatusChanged)

Notification so you can be informed if the user enables or disables voiceover.通知,以便您在用户启用或禁用画外音时收到通知。 For more on this see the following blog post.有关这方面的更多信息,请参阅以下博客文章。 < http://useyourloaf.com/blog/2012/05/14/detecting-voiceover-status-changes.html > < http://useyourloaf.com/blog/2012/05/14/detecting-voiceover-status-changes.html >

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

相关问题 UIAccessibility和Apple Pay旁白互动问题 - UIAccessibility and Apple Pay voice-over interaction issue 有什么方法可以禁用 UITextField 中占位符文本的可访问性画外音吗? - Is there any way to disable accessibility voice-over of placeholder text in UITextField? 辅助功能:将焦点移动到UITableViewController中tableView中的第一个单元格 - Accessibility: Moving voice over focus to the first cell in tableView in UITableViewController 画外音模式 - 滚动到滚动视图中不在视图中的子视图 - Voice over mode - Scrolling to subviews that are off view in scrollview 我可以声明应用程序范围的首字母缩写词替代画外音吗? - Can I declare app-wide acronym substitution for voice-over? 辅助功能:在Voice-over模式下设置slider.value时,不会发布UISlider的UIControlEventValueChanged - Accessibility: UISlider's UIControlEventValueChanged is not posted when slider.value is set in Voice-over mode 在UITextView上设置语音焦点 - Set voice over focus on UITextView 表格视图单元格上的标签被切断 - Label cut off on Table View Cell 画外音:单独读取表格单元的项目-而不是整体 - Voice over: Read items of table cell separately - not as a whole 表格视图底部(单元格)被切除 - Bottom of Table View (Cell) cut off
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM