iPhone:使用XIB通过完成按钮操作重新启动键盘

goo*_*guy 5 iphone uikeyboard

嗨,我正在UITextview上工作

如何辞职键盘,键盘"完成按钮"后单击动作,哪个XIB

谢谢

goo*_*guy 11

嗨,如果你想回答,用键盘上的默认"完成"按钮重新启动UITextview的键盘,那么这就是答案

- (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;
}
Run Code Online (Sandbox Code Playgroud)

如果有任何疑虑通知我,我按照这个来取消UITextview的键盘

谢谢


Rob*_*Cat 9

创建IBAction并在IB把它挂到UITextfieldDidEndOnExit事件.然后打电话[textViewName resignFirstResponder]让键盘消失.

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