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

    }

  • 相关阅读:
    开源数学库
    ZendFramework综述
    MySQL临时表
    GMP for PHP
    ubuntu的LAMP环境搭建
    linux与windows区别
    js对象与打印对象
    MySQL 多库操作
    ubuntu文件系统综述
    波形声音整理资料(for Project1)
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3711444.html
Copyright © 2011-2022 走看看