Created
April 5, 2017 07:21
-
-
Save allenatwork/9e1cec5cf45847e20b9fcf5f5c1285d3 to your computer and use it in GitHub Desktop.
Show done button for UITextView
This file contains 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
// Add toolbar to above keyboard | |
UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; | |
numberToolbar.barStyle = UIBarStyleBlackTranslucent; | |
numberToolbar.items = [NSArray arrayWithObjects: | |
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], | |
[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)], | |
nil]; | |
[numberToolbar sizeToFit]; | |
_tvContent.inputAccessoryView = numberToolbar; | |
// Action when click done | |
- (void) doneWithNumberPad{ | |
[_tvContent resignFirstResponder]; | |
} | |
// Doi voi TextField thì có thể trực tiếp hiện nút done ở keyboard | |
_tfTitle.returnKeyType = UIReturnKeyDone; | |
// Sau do | |
- (BOOL)textFieldShouldReturn:(UITextField *)textField { | |
//eturn YES; | |
// [self.view endEditing:YES]; | |
[textField resignFirstResponder]; | |
return YES; | |
} | |
// Remember : controller phai implement TextFieldDelegate | |
textField.delegate =self |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment