gpt4 book ai didi

objective-c - 无法关闭键盘

转载 作者:行者123 更新时间:2023-11-29 04:49:27 26 4
gpt4 key购买 nike

当完成或触摸文本字段之外的内容时,我不知道如何关闭键盘。这是我尝试的方法

myController.h

@interface myController : UIViewController <UITextFieldDelegate>{
secondViewController *secondView;
}

myController.m

-(void)loadView
{
.....
textFieldRounded.borderStyle = UITextBorderStyleRoundedRect;
textFieldRounded.textColor = [UIColor blackColor];
textFieldRounded.font = [UIFont systemFontOfSize:17.0];
textFieldRounded.placeholder = @"<enter text>";
textFieldRounded.backgroundColor = [UIColor whiteColor];
textFieldRounded.autocorrectionType = UITextAutocorrectionTypeNo;
textFieldRounded.keyboardType = UIKeyboardTypeDefault;
textFieldRounded.returnKeyType = UIReturnKeyDone;
textFieldRounded.clearButtonMode = UITextFieldViewModeWhileEditing;
[textFieldRounded.delegate = self;
[self.view addSubview:textFieldRounded];

....
}

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
return [textField resignFirstResponder];
}

最佳答案

用途:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {

当您触摸文本字段之外时进行捕获

关于objective-c - 无法关闭键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9113264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com