zoukankan      html  css  js  c++  java
  • 点击return收回键盘(不用inputview)

    -(void)setText:(NSString*)text placeHold:(NSString*)str secureTextEntrytextField:(BOOL)B

    {

        _textField.autocapitalizationType=UITextAutocapitalizationTypeNone;

        [_textFieldaddTarget:selfaction:@selector(returnKey:) forControlEvents:UIControlEventEditingDidEndOnExit];

        

        _textField.text = text;

        _textField.placeholder=str;

         _textField.secureTextEntry=B;

        

    }

    -(void)returnKey:(UITextField*)sender

    {

        [sender resignFirstResponder];

    }

    上面是自己写的一个方法.

    注意forControlEvents:UIControlEventEditingDidEndOnExit.当文本控件内通过按下回车键(或等价行为)结束编辑时,发送通知。

    所以要定义方法returnKey中的参数为(UITextField*)sender类型,也就是文本类型.

    resignFirstResponder 在文本框需要输入文字的时候,此时的键盘也就是所谓的第一响应者,也就是焦点,取消第一响应者也就是取消了键盘.

  • 相关阅读:
    bzoj 2216 Lightning Conductor
    一些有趣的问题合集
    Codeforces 40E Number Table
    Codeforces 37D Lesson Timetable
    bzoj 4289 Tax
    bzoj 2844 albus就是要第一个出场
    bzoj 2115 Xor
    luogu 3790 文艺数学题
    bzoj 1420 Discrete Root
    Lucas定理学习笔记
  • 原文地址:https://www.cnblogs.com/xukunhenwuliao/p/3462748.html
Copyright © 2011-2022 走看看