Skip to content

Instantly share code, notes, and snippets.

@dsappet
Created October 21, 2016 17:20
Show Gist options
  • Select an option

  • Save dsappet/720575ede2b768bf4df38e79b39c3755 to your computer and use it in GitHub Desktop.

Select an option

Save dsappet/720575ede2b768bf4df38e79b39c3755 to your computer and use it in GitHub Desktop.
Some simple useful stuff for xamarin ios
/// <summary>
/// Call it to force dismiss keyboard when background is tapped
/// Just call this in the viewdidload() of a controller and any keyboard will dismiss on tapping outside the keyboard
/// </summary>
protected void DismissKeyboardOnBackgroundTap()
{
// Add gesture recognizer to hide keyboard
var tap = new UITapGestureRecognizer { CancelsTouchesInView = false };
tap.AddTarget(() => View.EndEditing(true));
View.AddGestureRecognizer(tap);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment