如果我返回“是”,那有什么区别?或“否”或“否”当我调用textFieldShouldReturn时 [英] what is the difference if i return "YES" or "NO" when i call textFieldShouldReturn

查看:311
本文介绍了如果我返回“是”,那有什么区别?或“否”或“否”当我调用textFieldShouldReturn时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是文本字段委托方法,但我对返回类型有疑问

This is the text field delegate method but i have doubt about return type

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
  [textField resignFirstResponder];

   return NO;
}  

这与使用不同返回类型的方法相同

and this is the same method with different return type

-(BOOL)textFieldShouldReturn:(UITextField *)textField
 {
   [textField resignFirstResponder];

   return YES;
 }

我们可以隐藏i手机中的键盘。但是返回类型YES或NO的含义是什么。我没有看到任何区别。

by both we can hide key board in i phone . but what is the meaning of return type "YES" or "NO". I am not seeing any difference.

推荐答案

textFieldShouldReturn是一个可以处理键盘上的Return按钮的地方。

The textFieldShouldReturn is a place where you can handle the Return button on the keyboard.

textFieldShouldReturn询问代表文本字段是否应该按下返回按钮。

textFieldShouldReturn asks the delegate if the text field should process the pressing of the return button.

如果你实现自己的用于处理返回按钮的代码应该返回NO,或者返回YES以便以默认方式处理。

If you implement your own code to process the return button you should return NO, or return YES for it to be handled in the default way.

IOS Docs状态:
文本只要用户点击返回按钮,字段就会调用此方法。点击按钮时,您可以使用此方法实现任何自定义行为。

The IOS Docs state: The text field calls this method whenever the user taps the return button. You can use this method to implement any custom behavior when the button is tapped.

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html

这篇关于如果我返回“是”,那有什么区别?或“否”或“否”当我调用textFieldShouldReturn时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆