Custom button in navigation bar does not work - iphone

I have added a custom button (subclass UIButton) to my navigation bar but the button does not change states when clicked.
The button is configured correctly as it does work in, for example, a table view.
All advice is welcome.

Have you tried subclassing UIBarButton instead of UIButton?

I got it working. What I forgot to implement was the method to change the button selection states.

Related

Can UITableViewController toolbar buttons be changed when in Edit mode?

I've created a Storyboard project with a simple TableViewController embedded in a NavigationController with a simple toolbar at the bottom of the TableView. All done through the storyboard using the NavigationController ShowsToolbar=Y method described in other posts.
Is it possible to change the bottom toolbar buttons when the TableView goes into Edit mode? For example the Apple Mail app toolbar buttons change when you click on Edit.
From what I understand my options are to programmatically add remove bar button items when the TableView goes into edit more or to change the Edit button to segue to another TableView set in Edit mode with its own navigation controller and toolbar.
I thought it would be a more commonly done thing and therefore more obvious how to do it but haven't found anything so far.

How to I conceal the search bar and make it appear when a button is pressed

How to make a SearchBar Controller hide itself when the view is loaded and then appears when a button is pressed before disappearing again when you scroll upwards. Snapping the search function right up and concealing it until the button is pressed again.
Am I doing this right? I've looked up tutorials and they all point to adding the Searchbar to a TableHeaderView. I wonder is there a TableHeaderview when the TableView is set to static.
Thanks a lot guys
This may not be what you're looking for but this will work.
In your viewdidload:
YourTextFied.alpha = 0.0
Change YourTextField to the name of your outlet and that will hide the code when the view loads.
When the button is pressed simply run the code:
YourTextField.alpha = 1.0
you can use view.hidden = true before the view get loaded and then view.hidden = false when button get pressed
Nevermind, I found a really good guide here to animate a searchbar at the navigation bar when the search button is pressed.
How to animate add UISearchBar on top of UINavigationBar
thanks!

Hiding ToolBar in a UIViewController

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
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setToolbarHidden:YES animated:YES];
}
May be it can help you....
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.
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.

UIActionSheet with non dismissing buttons

I want to rise a UIActionSheet with one normal "Cancel" button as usual, but with a few non-dismissing buttons, as all buttons on action sheet dismiss the sheet when touched down.
I've tried to add UIButtons using addSubView but Im having a tough time dealing with the ActionSheet size.
Any advice?
TY!
I don't believe you can do this with a UIActionSheet.
You could however create your own view that looks like an ActionSheet and add it to the View in question. Add some core animation to make it slide up and down and viola! You'd have a custom UIActionSheet!

How to hide back button in the first view on iPhone?

I add 3 views for an application and they need to switch from 1-2-3.
Now I add a toolBar and a button 'OK' on the bottom of SwitchViewController, so they can share the button to go to next view.
But how to add a 'Back' button so that I can switch from 2-1 or 3-2 and the button shouldn't be seen in the first view?
Are there any other ways to switch views without sharing the same tool bar button?
It sounds like what you're trying to do is use a UINavigationController. If you instantiate a UINavigationController with the initWithRootViewController initializer you can pass it your first UIViewController. Then you just need to tie whatever action you want to a method that calls [myUINavigationController pushViewController:myOtherViewController animated:YES] to get it to slide over to the second view. The UINavigationController will automatically set up the UINavigationBar and back button you are looking for.