Skip to content

Instantly share code, notes, and snippets.

@sam33r
Created April 15, 2014 21:23
Show Gist options
  • Select an option

  • Save sam33r/10776947 to your computer and use it in GitHub Desktop.

Select an option

Save sam33r/10776947 to your computer and use it in GitHub Desktop.

Revisions

  1. sam33r created this gist Apr 15, 2014.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // Useful for when the keypad is open.
    // In the view controller:

    - (void)viewWillAppear:(BOOL)animated
    {
    [super viewWillAppear:animated];

    // Listen for taps to end editing
    UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
    [self.view addGestureRecognizer:gestureRecognizer];
    }

    - (void)tap:(UIGestureRecognizer *)ui
    {
    [self.view endEditing:YES];
    }