iPhone: 键盘使用按钮操作辞职 Done 通过 XIB

嗨,我工作 UITextview

如何在键盘后放弃键盘 "Done button" 按一个动作 XIB

已邀请:

莫问

赞同来自:

嗨,如果你想回答键盘 UITextview 默认按钮 "Done" 在键盘上,这是它的答案


- /BOOL/textView:/UITextView */textView shouldChangeTextInRange:/NSRange/range 
replacementText:/NSString */text {

// Any new character added is passed in as the "text" parameter

if/[text isEqualToString:@"\n"]/ {

// Be sure to test for equality using the "isEqualToString" message

[textView resignFirstResponder];

// Return FALSE so that the final '\n' character doesn't get added

return NO;
}

// For any other character return TRUE so that the text gets added to the view

return YES;
}


我遵循这一点来从键盘辞职 UITextview, 如果有任何恐惧,请告诉我

风见雨下

赞同来自:

创建
IBAction

和在 IB 将它连接到活动
UITextfield

's
DidEndOnExit

. 然后打电话
[textViewName resignFirstResponder]

, 删除键盘。

或者,尝试使用
[self.view endEditing:YES]

在 IBAction.

石油百科

赞同来自:

分配一个按钮
Done

键盘:

在这些例子中
myTextView

- 这是
UITextView

, 其中在标题中定义并连接到 Interface Builder.


-/BOOL/textViewShouldReturn:/UITextView*/textView {
if /textView == myTextView/ {
[textView resignFirstResponder];
}
return YES;
}


要分配外部按钮:

务必确定
IBAction

在他的标题然后在 Interface Builder 将按钮连接到此操作
touchUpInside:


.h


-/IBAction/dismissKeyboard:/id/sender;


.m


-/IBAction/dismissKeyboard:/id/sender {

[myTextView resignFirstResponder];

}

小明明

赞同来自:

称呼
resignFirstResponder

在 textview, 这具有拒绝键盘的焦点。

要回复问题请先登录注册