[英]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.