[英]Table view doesn’t scroll with voiceover focus
我能够使用 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.