Shivbaba's son
Shivbaba's son

Reputation: 1369

KeyBoard Did hide Method I need Animation?

Actually I have a text field.

the purpose is to show and hide the keyboard using views and scroll view.

Everything is fine but whenever keyboard hides view is falling without any animation. I mean it is very fast not looking good on my iphone.

I want view to fall down slowly.!!!!

For that mainly I am using this code..

CGPoint p=CGPointMake(0,0);
[srlvJuiceandSmoothireDetail1 setContentOffset:p animated:YES];

Can I set animation duration, Actually I also dont know that this method is worth or not.

On keyboard show it is worth...

Some Code..for refrence...

- (void) keyboardDidHide:(NSNotification *)notif {
    if (!keyboardVisible_) {
        NSLog(@"%@", @"Keyboard already hidden.  Ignoring notification.");
        return;
    }

//    CGRect viewFrame = scrlView;
    srlvJuiceandSmoothireDetail1.frame = scrlView;
    CGPoint p=CGPointMake(0,0);
    [srlvJuiceandSmoothireDetail1 setContentOffset:p animated:YES];

    keyboardVisible_=NO;

   }

Upvotes: 0

Views: 1076

Answers (3)

CIFilter
CIFilter

Reputation: 8677

You can animate certain UIView properties, including the frame. See the documentation for UIView for more information about how this is done.

Here's what you probably want:

NSTimeInterval duration = [[[notif userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

[UIView animateWithDuration:duration animations:
^{
    srlvJuiceandSmoothireDetail1.frame = scrlView;
}];

Upvotes: 2

Shivbaba's son
Shivbaba's son

Reputation: 1369

Actually Above answer and Notification if we use UIKeyboardWillShow will work instead of

UIKeyboardDidShow together nice.

Also I have setted time duration manually.

Upvotes: 0

Vov4yk
Vov4yk

Reputation: 1080

Did you try to hide the keyboard this way: Create the method of you view:

-(IBAction)hideKeyboard:(id)sender
{
    [*Your text filed* resignFirstResponder];
}

by default it makes keyboard hide with animation. Sorry, if I don't understand you question correct.

Upvotes: 0

Related Questions