画外音:每次加载视图时,ViewWillAppear 中的 UIAccessibilityLayoutChangedNotification 都不会将焦点设置在导航栏标题上

Voice over : UIAccessibilityLayoutChangedNotification in ViewWillAppear is not setting focus on Navigation bar title every time the view is loaded

过去 2 天我一直在努力解决这个问题。 我有一个 UITabBarController,每个选项卡在视图中都有一个 UINavigationController。 当我加载选项卡栏控制器时,画外音正在正确读取选项卡视图导航栏标题。它在第一次加载视图时起作用。(似乎这是默认行为。)但是当我再次 select 选项卡时,画外音正在阅读选项卡信息但没有将焦点设置到导航栏标题.有没有办法在每次加载选项卡视图时将其设置为专注于标题。 我尝试使用

override func viewWillAppear(_ animated: Bool) {
   super.viewWillAppear(animated)     

   UIAccessibilityPostNotification 
            (UIAccessibilityLayoutChangedNotification, self.navigationItem.titleView)
}

我还尝试创建一个标签作为标题视图并将其设置为 NavigationItem

没有任何帮助。

非常感谢任何建议。

谢谢。

在 viewDidAppear 中尝试,而不是在 viewWillAppear 中尝试

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.navigationItem.titleView);
    });
}