Created
September 9, 2014 17:32
-
-
Save chrisdiana/04431f0c8cf75a1e90a7 to your computer and use it in GitHub Desktop.
Add Done and Dismiss Keyboard for UITextView in Xamarin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample text box | |
var deedDescriptionField = new UITextView (new RectangleF (0, 230, UIScreen.MainScreen.Bounds.Width, 100)){ | |
BackgroundColor = UIColor.White, | |
Text = " Description:", | |
TextColor = ViewHelpers.DarkGray, | |
Font = UIFont.FromName("Helvetica", 18f) | |
}; | |
// change the return key to done | |
descriptionField.ReturnKeyType = UIReturnKeyType.Done; | |
// dismiss keyboard on done | |
descriptionField.ShouldChangeText = (text, range, replacementString) => { | |
if (replacementString.Equals ("\n")) { | |
deedDescriptionField.EndEditing (true); | |
return false; | |
} else { | |
return true; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment