zoukankan      html  css  js  c++  java
  • UItextField弹出数字键盘以及隐藏键盘

    设置UItextField的边框

    [resultTextFieldsetBorderStyle:UITextBorderStyleRoundedRect];

     

    弹出数字键盘:

    将UITextField的keyboardType设置为:

    UIKeyboardTypeNumberPad

    就能弹出数字键盘

     

    键盘类型

    typedef enum {
        UIKeyboardTypeDefault,      默认键盘,支持所有字符         
        UIKeyboardTypeASCIICapable, 支持ASCII的默认键盘
        UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘,支持+*#字符
        UIKeyboardTypeURL,            URL键盘,支持.com按钮 只支持URL字符
    UIKeyboardTypeNumberPad,             数字键盘
    UIKeyboardTypePhonePad,   电话键盘
        UIKeyboardTypeNamePhonePad,  电话键盘,也支持输入人名
    UIKeyboardTypeEmailAddress,  用于输入电子 邮件地址的键盘     
    UIKeyboardTypeDecimalPad,    数字键盘 有数字和小数点
        UIKeyboardTypeTwitter,       优化的键盘,方便输入@、#字符
        UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, 
    } UIKeyboardType;

     

    隐藏键盘:

    1、点击空白处隐藏键盘

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

    {

        [resultTextFieldresignFirstResponder];

        [resultTextFieldresignFirstResponder];//点击空白处也要隐藏键盘

    }

     

    2、点击return按钮键盘消失

    -(BOOL)textFieldShouldReturn:(UITextField *)textField

    {

        [textField resignFirstResponder];

        returnYES;

    }

     

    -(void)textFieldDidEndEditing:(UITextField *)textField

    {

        [textField resignFirstResponder];

    }

  • 相关阅读:
    Python2和3版本对str和bytes类型的处理
    使用Fiddle对夜神模拟器进行抓包的设置
    WebSocket 实现链接 群聊(low low low 版本)
    WebSocket 实现链接 发送消息
    Linux文件操作命令
    Linux命令格式
    FastJson
    JSON语法规则
    Mybatis resultMap支持继承
    Mybatis在xml文件中处理大于号小于号的方法
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3711444.html
Copyright © 2011-2022 走看看