我正在处理一个表视图,当用户点击一个特定的单元格时,它就会展开,视图就会像附加的图像中的那样被设置。

我的问题与无障碍有关。当底部的按钮超出屏幕时(如iPhone 6s这样的小屏幕),画外音聚焦于它们,但表视图不会将它们滚动到视图中。此外,当我激活(双击与语音转换启用)的焦点按钮,他们不工作。但是,当按钮是可见的,我可以激活按钮的声音覆盖。如何使按钮在较小屏幕上滚动到视图中?
发布于 2022-02-19 06:57:25
我用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];
}
}
}https://stackoverflow.com/questions/71144089
复制相似问题