Reputation: 580
I have a UIViewCOntroller
, and in that i have a button and a text field. When i click the button i display a UIToolBar
.
Now when i click anything in the background (the textfield or the blank view) i need this UIToolBar
to disappear. How can i do this programmatically ?
I know how to add a UIToolBar
but all what i need to know is to hide it when the user clicks on the background.
I don't think i will have to paste any code here or show my workings so far, coz i have no clue how to get this done
Upvotes: 1
Views: 2300
Reputation: 9544
The easiest way to do this is to make a single large clear button that is behind the first button but above everything else. Normally have it set to hidden but when you show the toolbar unhide the button as well. When the button is clicked have it hide the toolbar and its self. No need to do anything crazy like sub classes.
Upvotes: 0
Reputation: 1506
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setToolbarHidden:YES animated:YES];
}
May be it can help you....
Upvotes: 7
Reputation: 9030
You will need to capture a touch on the views outside of your toolbar to achieve this. If you have a custom UIView base class that all of your other views use, you might start there. Otherwise, perhaps use some sort of toggle to show/hide your toolbar instead in your UIViewController.
Upvotes: 0