欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

ios学习记录 UITextField输入return键监听

发布时间:2025/6/15 编程问答 38 豆豆
生活随笔 收集整理的这篇文章主要介绍了 ios学习记录 UITextField输入return键监听 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

2019独角兽企业重金招聘Python工程师标准>>>

#import <UIKit/UIKit.h>@interface ViewController : UIViewController<UITextFieldDelegate>{IBOutlet UITextField *_textField;} - (IBAction)pressButton:(UIButton *)sender; @end #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {[super viewDidLoad];_textField.delegate=self;// Do any additional setup after loading the view, typically from a nib. } - (BOOL)textFieldShouldReturn:(UITextField *)textField{[self pressButton:nil];return YES; } - (IBAction)pressButton:(UIButton *)sender {if([_textField isFirstResponder]){[_textField resignFirstResponder];}} @end


转载于:https://my.oschina.net/liyang2l/blog/76243

总结

以上是生活随笔为你收集整理的ios学习记录 UITextField输入return键监听的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。