Objective c - Is there a way to change a leftBarButtonItem with animation? - iphone

In some point in my app, I'm programmatically change the leftBarButtonItem of a viewController (I'm changing the entire button look not just the text).
The result is that the button indeed changes but at once, but I want to do it with some animation (The same way it would do the animation to left navigation bar if I push a viewController)
Is it possible?

There is a method specifically for that, called setLeftBarButtonItems:animated:
It animates the change in bar button items for you.

Related

How to disable backBarButtonItem displayed in current view?

After a view has been pushed onto the UINavigationController stack and is displayed I need to disable the Back button under certain circumstances, e.g., when data is being edited on that screen.
The following hides the Back button
self.navigationItem.hidesBackButton=YES;
but I need to disable it.
There are several other answers about how to hide it or suggest not displaying it in the first place, but these are not what I need to implement.
You could implement one of the delegate methods for your navigationController's navigation bar delegate. Take a look at the [UINavigationBarDelegate navigationBar:shouldPopItem:] method.
Returning YES or NO from this method will enable or disable the back button.
You could implement one leftBarButtonItem (invisible and without effect)
add it into your current view (self.navigationItem.leftBarButtonItem)
and remove it to access your backButton.
If you're fine that the whole navigation bar is disabled, an easy solution is
self.navigationController.navigationBar.userInteractionEnabled = NO;
Of course this doesn't work if you have other bar buttons that you want to keep enabled.

using UINavigationBar without UINavigationController

I want a UINavigationBar at the top of my UIWebView but I want to control by hand the title, the back button, what the back button does - etc. In other words I never want to push or pop views. I just want to change the UINavigationBar contents as the user clicks around the web view.
Where I'm up to is I added the UINavigationBar to my superView and made it 44 pixels tall. How do I set the title since I have no navigationItem? How would I set a fake back button up?
I would appreciate any pointers. I realise this is quite weird what I'm doing.
Thanks :)
The answer, if anyone's interested, is in the class reference of UINavigationBar.
When you use a navigation bar as a standalone object, you are
responsible for providing its contents. Unlike other types of views,
you do not add subviews to a navigation bar directly. Instead, you use
a navigation item (an instance of the UINavigationItem class) to
specify what buttons or custom views you want displayed. A navigation
item has properties for specifying views on the left, right, and
center of the navigation bar and for specifying a custom prompt
string.
In short, use a UINavigationItem and apply it by "pushNavigationItem" on the UINavigationBar.
I created a subclass of UINavigationBar called StaticNavigationBar which I can then load with any state by putting the appropriate UINavigationItem's on it. Thanks for all your answers people.
You can have that UINavigationBar as an outlet and then you can manupulate it as you want. So you don't have to refer to somebody's navigation item. It'll be an independent (sort of) object on your view.
If you dont want the navigationbar as-is youll have to roll your own.
if youre ok with the built in animations for pushing and popping items(dont confuse with push/pop of viewcontrollers) to the bar you would then set your UINavigationBarDelegate and use its methods for controlling how things push/pop, etc.

flip animation for right navigation bar button item

What is the best way to have the right navigation bar button flip like it does in the ipod when one changes from list view to single song view? Subclass a custom view? Are there any api's out there that already do this?
thanks
This question is similar, and discusses a few solutions. The main issue is that the UIBarButtonItem isn't a UIView, so you can't use the UIView transitions. iPhone flip right button (like iTunes)

How to present a modal view controller with fixed UIToolbar?

I am trying to set up a Modal View Controller, that that lies below a fixed toolbar. therefore the toolbar is supposed to stay on top while the modal view rolls in.
the Safari-App does that for example, when hitting the bookmarks-button. the toolbar stays, the buttons change..
I tried a couple of things like pushing the toolbar to the front and ended up not using the presentModalViewController method at all, and animating the new View manually into a subview instead. but that brought a couple of other issues along.
I'm not sure what you are saying, when you press add bookmark in safari, a new modal view shows with no tool bar. The navigation bar at the top is not a tool bar if that is what you mean. They are UIToolbarItem set into self.navigationItem.
All modal views I've seen are animated until they take up the whole of the screen. Those modal-like views that only scroll up to a certain point in some apps, are done by hand. Maybe you can cover those issues encountered when doing this by hand in another post?

Assigning a IBAction to the Back Button of the Navigation Bar (iPhone SDK)

In this (Flip View Iphone) post, I have created a flip view for my iPhone app.
Now, I want to make sure that whenever the user hits the 'Back' button in the navigation bar, the next time around when he drills down to the flippable view, this view is in its original, non-flipped position. Currently, the app actually loads the correct view, but somehow, when you try to flip it over, it cannot doesn't load the flip view, and presents a black background only.
One solution could be to assign the flip back method ("showLessInfo") to the navigation button, and that is what I need your help for.
Alternatively, and quite likely a better idea for me would be to understand, why the flip view is not loaded the second time around.
Any suggestion is welcome!
You can override the viewWillAppear: method on your flip view's view controller and make sure behind the scenes it loads the proper view before showing (remember to call [super viewWillAppear:animated]).
Or else, you could override the viewWillDisappear and make sure things are cleaned up on the way out. It will get invoked when the user taps the back button.