hidesBackButton不起作用

hidesBackButton不起作用

本文介绍了为什么self.navigationItem.hidesBackButton不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIViewController ,它被推送到 UINavigationController 并且当前显示。当我在视图控制器中启动一些异步任务时,我可以将self.navigationItem上的 hidesBackButton 设置为 YES ,并且正确隐藏后退按钮。

I have a UIViewController that is pushed onto a UINavigationController and is currently displayed. When I go to start some asynchronous task inside the view controller, I can set hidesBackButton on self.navigationItem to YES, and the back button is hidden correctly.

任务完成后,我将 hidesBackButton 设置回(在UI线程上,我可能会添加,我已经确定了这一点),没有任何反应。后退按钮保持隐藏状态。

As soon as the task is finished, and I set hidesBackButton back to NO (on the UI thread, I might add, I've made sure of this), nothing happens. The back button remains hidden.

有没有人见过这个?让我特别疯狂的是,在我的应用程序(相同的应用程序)中,在不同的 UINavigationController 层次结构中,完全相同的代码正常工作!

Has anyone seen this before? What drives me especially crazy is that in my application (the same application), in a different UINavigationController hierarchy, the exact same code works correctly!

推荐答案

你是否从线程中调用hidesBackButton = NO?所有UI操作都应该在主线程上完成,否则它们不会有任何影响。

Are you calling hidesBackButton = NO from a thread? All UI operations should be done on the main thread, otherwise they won't have any effect.

这篇关于为什么self.navigationItem.hidesBackButton不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:23