gpt4 book ai didi

iphone - 当用户点击其他地方时,如何从文本字段中退出第一响应者?

转载 作者:IT王子 更新时间:2023-10-29 07:56:26 32 4
gpt4 key购买 nike

我已经用 ScrollView(与 View 大小相同)填充了我的 View ,但当用户点击 View (或 ScrollView )中的其他地方时,我仍然不知道如何退出第一响应者。关于如何做到这一点的任何想法?我正在使用以下方法,但它没有按预期工作:

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

感谢您的帮助,

史蒂芬

最佳答案

我找到了答案 here :

If your ultimate aim is just to resign the first responder, thisshould work: [self.view endEditing:YES]

endEditing(_:)方法是为它设计的

Causes the view (or one of its embedded text fields) to resign the first responder status.

关于iphone - 当用户点击其他地方时,如何从文本字段中退出第一响应者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7794959/

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