ios菜鸟之路:textfield隐藏键盘以及点击背景取消键盘

一、点击Done按键隐藏键盘:

//在头文件.h中 初始化

@property (strong, nonatomic) IBOutlet UITextField *account_reg_TextField;
@property (strong, nonatomic) IBOutlet UITextField *passwd_reg_TextField;
@property (strong, nonatomic) IBOutlet UITextField *check_passwd_reg_TextField;

//action 事件选择 did end on exit

- (IBAction)textfieldDoneEditing:(id)sender;
- (IBAction)paswdDoneEditng:(id)sender;

- (IBAction)checkpasswdDoneEditing:(id)sender;

//在.m文件中实现方法

- (IBAction)textfieldDoneEditing:(id)sender {
    [account_reg_TextField resignFirstResponder];
   
}

- (IBAction)paswdDoneEditng:(id)sender {
    [passwd_reg_TextField resignFirstResponder];
}

- (IBAction)checkpasswdDoneEditing:(id)sender {
     [check_passwd_reg_TextField resignFirstResponder];
}

二、帅帅的背景点击取消键盘

选择视图,在最右边的custom class中选择UIButton 即把背景改成了button事件

- (IBAction)backgroundbutton:(id)sender;

//.m文件的实现

- (IBAction)backgroundbutton:(id)sender {
    [account_reg_TextField resignFirstResponder];
    [passwd_reg_TextField resignFirstResponder];
    [check_passwd_reg_TextField resignFirstResponder];
}

可以了吧 嘻嘻

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值