简体   繁体   English

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

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

I have been struggling for last 2 days to figure this out. 最近两天我一直在努力寻找答案。 I have a UITabBarController and each tab has a UINavigationController with in the view. 我有一个UITabBarController ,每个选项卡在视图中都有一个UINavigationController When i load the tab bar controller voice over is reading the tab view navigation bar title correctly. 当我加载选项卡栏控制器时,画外音正确读取了选项卡视图导航栏标题。 It works for the first time the view is loaded.(Seems like that is the default behavior.) But when i select the tabs again, voice over is reading the tab information but not setting the focus to the navigation bar title. 它在第一次加载视图时起作用。(似乎是默认行为。)但是当我再次选择选项卡时,画外音正在读取选项卡信息,但没有将焦点设置到导航栏标题上。 Is there a way to set it to focus on the title every time the tab view is loaded. 有没有一种方法可以将其设置为每次加载选项卡视图时都将焦点放在标题上。 I tried using 我尝试使用

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

   UIAccessibilityPostNotification 
            (UIAccessibilityLayoutChangedNotification, self.navigationItem.titleView)
}

I also tried creating a label as title view and setting it up as a NavigationItem . 我还尝试过将标签创建为标题视图,并将其设置为NavigationItem

Nothing helped. 没有任何帮助。

Any suggestions are greatly appreciated. 任何建议,不胜感激。

Thankyou. 谢谢。

Try in viewDidAppear not in viewWillAppear 在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);
    });
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM