UINavigationBar back button disappears - iphone

I have lost a lot of time with this weird error/bug.
I have 2 ViewControllers with navigationController and I move from the first to the second with pushViewController. But when I push second viewController, it shows up and also backButton on the navigation bar shows up. But this button disappear in a very short time (about half a second). Title of the first viewC is ok and it`s also on the back button (I can catch it in the time it is shown up).
Does anyone have a tip where could be the problem? I am lost in this time...
Thanks

OK. I'm an idiot. A forgot that I clear content including title in my viewDidDisappear. So the conclusion for the future generations... "when you have problems with backBarButton - it's 99% error with the previous viewController's title or you are hiding that button somewhere"...

Related

UIButtons don't align correctly upon first load of View Controller

I have a ViewController/View in a TabBar Controller that has 8 UIButtons in a 2x4 grid, sized 75x75, each with a 75x75 background image set on them. Currently, I've hard coded the XY positions in the Size Inspector in Interface Builder.
When I first load the View, by clicking on the tab bar icon, the bottom two buttons get squished against the row above them - as per this picture:
Each button triggers a segue that launches another ViewController with a WebView in it :
[self performSegueWithIdentifier:#"playVimeo" sender:sender];
In that WebView, there is a back button that triggers another segue to return to the thumbnails page :
[self performSegueWithIdentifier:#"returnToThumbnails" sender:sender];
When I press the back button and return to the thumbnail view for a second time, the buttons snap to the right place, unlike when they first load, as per this picture:
Here is a screenshot of my Storyboard:
Does anyone have an idea what is going on here ? I am lost...
Thanks in advance!
Jesse
This issue went away when I unselected "Use Autolayout" in the file inspector of the UIViewControllers.
Though as rdelmar pointed out in the comments, it is funny that it was working at all, as I was actually creating a new ViewController with every segue from my back button, and not popping back to the previous existing ViewController. It should have been working the same in both ways, as the View was always loading 'for the first time' ...

becomeFirstResponder does not show keyboard second time (ios 6 + storyboard)

I have a storyboard, which includes navigation between views. Back and forth, and there is also the possibility to jump all the way to the home screen.
Basically, it works like this:
View 1 shows a simple menu.
View 2 shows input fields and automatically shows the keyboard.
View 3 shows a results table. In this view one can go one step back (to view 2) or back to the home screen (view 1).
The keyboard and everything works perfectly the first time, when the user moves from view 1 to view 2. However, when moving either back from view 3 to view 2, or from view 3 and starting all over again, the keyboard does not show.
In the code, I have becomeFirstResponder in the viewDidAppear method. Also, it will resignFirstResponder when loading view 3. Another interesting fact is that when calling the becomeFirstResponder for the second time, it does return NO (while it returns YES the first time). Also, when returning back to this view the textfields are not possible to select, even though they are userInteractionEnabled.
I am really stuck here, so any help is highly appreciated.
I have seen several similar questions to this one, but not found a solution:
becomeFirstResponder seems to work only 1st time for shake gesture
Adding [myUITextField becomeFirstResponder]; does not bring up keyboard
keyboard not responding to resignFirstResponder
UITextField becomeFirstResponder works only once
I was able to track down the problem in my code. Answering this question myself since it might be helpful to others as well.
My issue was that I didn’t really get the order of events correct. I had a button that would move to the next textfield, and if everything was completed it would move to the next screen. This caused the becomeFirstResponder method to be called and not released (resignFirstResponder) when switching to a new screen.
I guess the main advice I can give (at least what finally worked for me), was to just go through all the becomeFirstResponder and make sure it is released before moving to next screen.

UITabBar and UIMenuControl not appearing after going to another tab and back

I have a UITabBar and a UIMenuControl but the problem is that when I click on the button and my MenuControl appears and then I switch to another tab and then when I come to the previous view and click that button again the UIMenuControl doesnot show up .
The UIMenuControl is not is no showing up when i come back from another tab.
I dont know what the problem is.
Whenever you want the tab bar to reappear, call:
self.tabBarController.hidden = NO;
If you are having trouble with losing it during a particular method, try putting this in that method.
The other possibility is that you are covering the first view completely. If this is the case, then be careful. You may be actually adding new views to the hierarchy every time you push a button. If you dont handle your memory management properly this would be a huge leak. A band-aid fix would be to call:
[self.view bringSubviewToFront:self.tabBarController];

UINavigationBar occasional glitch

When I press back twice really quickly on the UINvaigationBar, then the UINavigationBar animates before the view, and then when the view finally animates the bar becomes blank. When I NSLog(#"",self.navigationItem.title) is prints the correct title. Does anyone have any ideas how to resolve this?
I've seen this happen when the init/loadView of a view controller that's being pushed takes a non-negligible time- perhaps the viewWillAppear of your new view controller or the viewDidDisappear of the old is taking some time?

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!
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.
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 :-)
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.
Have you tried using the setHidesBackButton:animated: method instead? Perhaps that has a slightly different behavior.
In my case I simply had to give a title to the view, as in:
self.navigationItem.title = #"Menu";
Marinus
I have had a similar issue recently. I tried literally everything I found in SO and other forums- nothing worked.
In my case there was a modally shown UINavigationController with a simple root controller which would push one of two view controllers (A and B) on top of the controller stack when the button A or B was pressed, respectively. Controller B was the one which was not supposed to show the back button. But still, sometimes it did, sometimes it didn't.
After hours of debugging, I managed to track it down. Controller A was a UITableViewController. Each time I selected a cell in this controller, the delegate would pop Controller A off the stack. BUT. I made use of a UISearchDisplayController as well. Turned out that popping the view while the search controller was still active messed up something in the navigation controller that made it impossible to hide the back button in Controller B afterwards (well, it eventually stayed hidden between viewDidLoad and viewDidAppear: but then it always turned visible).
So the solution (rather workaround) was adding this line to where Controller A was dismissed:
controllerA.searchDisplayController.active = NO;
// ...
// [self.navigationController popViewControllerAnimated:YES];
Hope this spares someone a couple of hours.