在“完成”上放弃键盘键盘按钮
我想通过单击键盘上的“完成”按钮来退出键盘。我该怎么做?我有以下代码 =>
textView.returnKeyType = UIReturnKeyDone;
我有这个代码用于限制 textview => 中的字符数
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if(range.length > text.length)
{
return YES;
}
else if([[textView text] length] >= MAX_LENGTH_TEXTVIEW && range.length == 0)
{
[textView resignFirstResponder];
return NO;
}
return YES;
}
单击键盘的“完成”按钮后如何退出键盘?如果我单击 Done ,它不会辞职,而是会转到下一行(即 \n )。是否有“完成”方法等的委托方法?我没有从苹果文档中获取“完成”的方法。 请帮助我....提前致谢...
I want to resign keyboard on click of 'Done' button on keyboard. How can i do this? I have following code =>
textView.returnKeyType = UIReturnKeyDone;
I have this code for limiting number of characters in textview =>
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if(range.length > text.length)
{
return YES;
}
else if([[textView text] length] >= MAX_LENGTH_TEXTVIEW && range.length == 0)
{
[textView resignFirstResponder];
return NO;
}
return YES;
}
How can i resign keyboard on clicking "Done" button of keyboard? If i click on Done , it's not resigning instead it is going to next line (i.e \n ). Is there any delegate method for "Done" method or so? i am not getting method for "Done" from apple documentation.
plz help me ....thanks in advance....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的委托应该实现 - (BOOL)textFieldShouldReturn: (UITextField *)textField 方法
Your delegate should implement - (BOOL)textFieldShouldReturn:(UITextField *)textField method
也许你可以在你的函数中添加另一段代码:
May be you can add another piece of code to your function: