Return to   |   Check out   |   How to Post Snippets  

Not registered? Thats okay! You can Submit a Snippet without being a member of this site!


Dismissing the keyboard before you do something else is just good UX. So for example we want to move to another screen, but want to make sure that the keyboard dismisses before this happens (because otherwise the keyboard would be in front of the push animation).

[self dismissKeyboard:^{
    [self performSegueWithIdentifier:@"SomeOtherView" sender:self];

So here, we set a delay for the completion to take place of .25f, otherwise, if no textfield is the firstResponder, then we complete the block immediately.

- (void)dismissKeyboard:(void (^)(void))completion
    float dismiss = .25f;
    if ( _tfFirst.isFirstResponder )
        [_tfFirst resignFirstResponder];
    else if ( _tfLast.isFirstResponder )
        [_tfLast resignFirstResponder];
    else if ( _tfEmail.isFirstResponder )
        [_tfEmail resignFirstResponder];
    else if ( _tfPassword.isFirstResponder )
        [_tfPassword resignFirstResponder];
    else if ( _tfPasswordConfirm.isFirstResponder )
        [_tfPasswordConfirm resignFirstResponder];
        dismiss = 0.f;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(dismiss * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

One Response to “Dismiss keyboard with completion block”

    Shopping for a new or used car can be quite a difficult process if you do not know what you are actually carrying out. By educating yourself about automobile buying before you decide to visit the dealer, you could make points simpler for your self. The following advice can help your next store shopping vacation be a little more enjoyable.

    Constantly bring a technician alongside when searching for a whole new vehicle. Auto retailers are notorious for promoting lemons and you do not desire to be their following target. If you can not get a mechanic to check out cars along with you, at the very least make certain you have him evaluate your last decision before you buy it.

    Know your limits. Prior to starting buying for your car or truck, make a decision how much you can manage to spend, and follow it. Don’t forget about to feature desire for your estimations. You will definitely spend around 20 % as an advance payment too, so be prepared.

    Before attending a dealer, know what kind of vehicle you would like. Analysis all you choices ahead of purchasing to help you figure out what works the best for your financial allowance and loved ones demands. Do your research to learn how much you ought to be paying to get a potential car.

    Before signing any agreement take the time to study each and every line, like the small print. When there is something outlined that you do not comprehend, do not indicator before you have an solution that you recognize. Unsavory salesmen may use a contract to put a lot of service fees which were not reviewed.

    In the event you maintain the previous assistance in your mind next time that you go purchasing a car, you will end up more prone to get a better offer. Getting a car does not have to be a head ache. Just use the guidelines using this write-up and you could get the vehicle you want at a great price.

Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© Copyright 2011 Wright's Computer Services.   All rights reserved Suffusion theme by Sayontan Sinha