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];

    }

  • 相关阅读:
    Postman基本使用
    一分钟应对勒索病毒WannaCry
    使用C语言和Java分别实现冒泡排序和选择排序
    C#快速读写文件
    从一个故事开始谈项目与团队管理
    JavaSE学习总结(八)
    npm 包的 发布 流程
    iOS开发UI篇—Quartz2D使用(矩阵操作)
    iOS开发UI篇—Quartz2D使用(图形上下文栈)
    iOS开发UI篇—Quartz2D简单使用(三)
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3711444.html
Copyright © 2011-2022 走看看