Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is self.navigationItem.hidesBackButton not working?

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.

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.

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!

like image 924
Rob Avatar asked Apr 02 '09 02:04

Rob


3 Answers

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.

like image 132
lostInTransit Avatar answered Oct 21 '22 00:10

lostInTransit


i have not been able to replicate your problem on my machine. however, i faced a similar issue with tableviews even when i was updating my ui on the main thread. but calling setNeedsDisplay fixed that issue.

Can you try this and see if this works:

[self.navigationController.navigationBar setNeedsDisplay];

I guess this should work, you need to do the same, BUT ON THE NAVIGATIONBAR instead. please let me know if this worked - as i cannot test my solution because i never get this problem :-)

like image 26
Raj Avatar answered Oct 21 '22 02:10

Raj


Have you tried forcing the view to refresh by calling setNeedsDisplay? Maybe the OS is not picking up the changes instantly and you need to force it.

like image 1
pgb Avatar answered Oct 21 '22 01:10

pgb