Animating a complete change in the toolbar - ios

I have a toolbar that, at some point in the application, is completely replaced by another toolbar (i.e. another set of toolbar items). How do I animate this replacement?
Note: An ideal animation would be that of sliding the old toolbar items out and sliding the new ones in.

I found the best way to do this is to use setToolbarItems:animate: on the active view, thus avoiding the need for another toolbar.

Please check this,
http://www.iphonedevsdk.com/forum/iphone-sdk-development/25045-navigation-controller-custom-animation.html

There is also a UIToolbar method that is called - (void)setItems:(NSArray *)items animated:(BOOL)animated which does the same as the one mentioned by nessup.

Related

Set layers programmatically

so I have an application with several images, buttons, etc.. Now, I would like to control programmatically which object is in the foreground and which is further in the back. I know that in the storyboard this is possible, but since I declare a button in the AppDelegate (I don't have in the storyboard) I can't use this function.
Now, is there a way to do this?
You have to use the property .zPosition to accomplish that.
Look at the "Managing View Hierachy" section on UIView to accomplish this.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/doc/uid/TP40006816-CH3-SW46
You can bring views to the front or send them to the back or adjust their index among others.
- (void)bringSubviewToFront:(UIView *)view

Changing UIToolBar (appearance) at runtime

I want to change an UIToolBar at runtime. In it's initial state, is has only one button, when that button is pressed i want it to change it's appearance to show 4 buttons. One of these buttons should cause the first UIToolBar to reappear.
Im seeing two approaches:
1) Have two UIToolBar nibs, and load them as needed.
2) Having all buttons on the first UIToolbar, and hide/show them as needed.
What would be the correct approach?
Personally, I would want to see all 4 button at initial launch with only relevant button in enabled state and rest in disabled state. Once I tap on the already enabled button I should see other buttons getting enabled. This is less surprising UI for end user. However, you can also go with #2 mentioned above in which case you might want to add some animation effect for better user experience.
The second approach would be better, because if you want to add more buttons tomorrow, you need to maintain 2 nib files instead of one.
But, think again is creating toolbar in xib file good solution?
I would create custom toolbar extending UIToolbar class and make 2 methods in it:
-(NSArray*) toolbarButtonsInitial;
-(NSArray*) toolbarButtonsExtended;
-toolbarButtonsInitial method returns UIBarButtonItems for initial state
-toolbarButtonsExtended method returns UIBarButtonItems for second state.
IMHO, this way has several advantages:
Your xib file doesn't have hidden buttons, or some button above other
one
If you need to add or remove some buttons you can do that easily for
each state
You can easily reuse this toolbar on other screens and create new
states if necessary

iOS TableView Form Navigation

When using Safari and filling out a form, there are three buttons conveniently located at the top of the keyboard labeled Previous, Next, and Done. Is there a keyboard setting that can enable those or do you have to create and program these buttons manually?
I've had some success using this library:
https://github.com/simonbs/BSKeyboardControls
There is no default property of keyboard provided in ios. You need to add toolbar for that. Then you add previous , next or done UIBarButtons in the toolbar.
When keyboard appears toolbar is also displayed above it using some animation or directly same way when it hides/disappears you have to hide the toolbar also using animations or by changing it positioning in view.
Hope it helps you.
XCDFormInputAccessoryView is an accessory which contains the features you needed. It is easy to use. Here is how it looks with keyboard

Suppress darkening of main view when UIActionSheet displays

I have a UIActionSheet and when it displays it darkens the main view behind it, I am under the impression this is default behavior for an action sheet. My question is, how do I override this behavior to leave the main screen the same tint as it normally is? I'm assuming I do something like:
mainView.alpha = 1f;
Or something...I can't remember if alpha needs to be maxed or 0 to leave a screen with the same coloration/transparency. Anyways, if that is correct where should it happen? My action sheet is being called in place of a keyboard for a UITextField.
Thanks in advance.
You can't change this behavior. UIActionSheet is actually presenting a whole new view overtop of your view. It's this additional view that adds the tint. There is no API to change this.
Your best solution is to implement your own custom equivalent to UIActionSheet so it does exactly what you want.

Custom input views: how to prevent them from fading during orientation change?

I am having trouble with assigning a UIControl subclass I made as a text field's inputView.
It shows - as expected - when the text field becomes firstResponder and hides when it resigns it firstResponder status.
However, the thing I am having trouble with is handling different orientations:
I set an autoresizingMask to the control's subviews so that there is a smooth transition when changing its width.
The thing is, they appear to be ignored as soon as I set it as the inputView.
When enabling the simulator slow-motion animations via triple-hitting shift, you can see very clearly that the view fades between the two states.
This is not what I want. Firstly it looks odd, and secondly this does not fit my needs.
Since the inputView contains a UIScrollView-like element, it would stop its deceleration animation during the fade.
Now my question is: Is there a way to prevent the fade from happening?
I would really like to use the inputView property since it saves me from writing lots of lines of code.
Also, is it possible to specify different heights for different orientations?
Here are two demo projects showing how it is and how I want it to be.
Thanks in advance.
You can create a method to your DatePicker class, that changes the geometry and layout of the view for different orientations and the implement the method
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
in your view controller and call the method on your view to align it.
Until today I have found no way to prevent them from fading.

Resources