gpt4 book ai didi

uitextfield - 关闭 UITextField 上的键盘

转载 作者:行者123 更新时间:2023-12-03 18:17:40 25 4
gpt4 key购买 nike

我是一个为 iOS 设备开发的新手。我在 InterfaceBuilder 上插入了一个 UITextField,并分配了代码:


@interface ComposeViewController : UIViewController {
id <ComposeViewControllerDelegate> delegate;
IBOutlet UITextField *notificationTitle;
}
当用户按下“返回”键时,如何允许关闭键盘?

最佳答案

将UITextField的Delegate设置为ViewController,在File's Owner和UITextField之间添加引用outlet,然后实现此方法:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == yourTextField) {
[textField resignFirstResponder];
}
return NO;
}

关于uitextfield - 关闭 UITextField 上的键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4761648/

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