gpt4 book ai didi

iphone - iPhone 中 textfieldshouldendediting 和 textfieldDidendediting 之间的区别

转载 作者:可可西里 更新时间:2023-11-01 03:27:50 27 4
gpt4 key购买 nike

textFieldShouldendEditingtextfieldDidEndEditing 有什么区别,什么时候应该使用每种方法?

最佳答案

textFieldShouldEndEditing:

Asks the delegate if editing should stop in the specified text field.

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField

Discussion This method is called when the text field is asked to resign the first responder status. This might occur when your application asks the text field to resign focus or when the user tries to change the editing focus to another control. Before the focus actually changes, however, the text field calls this method to give your delegate a chance to decide whether it should.

Normally, you would return YES from this method to allow the text field to resign the first responder status. You might return NO, however, in cases where your delegate detects invalid contents in the text field. By returning NO, you could prevent the user from switching to another control until the text field contained a valid value.

textFieldDidEndEditing:

Tells the delegate that editing stopped for the specified text field.

- (void)textFieldDidEndEditing:(UITextField *)textField

讨论在文本字段退出其第一响应者状态后调用此方法。您可以使用此方法更新委托(delegate)的状态信息。例如,您可以使用此方法来隐藏只应在编辑时可见的叠加 View 。委托(delegate)对这个方法的实现是可选的。

site:apple.com textFieldShouldendEditing

textFieldShouldEndEditing

textFieldDidEndEditing

关于iphone - iPhone 中 textfieldshouldendediting 和 textfieldDidendediting 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12262909/

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