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

    }

  • 相关阅读:
    ASP.NET MVC 异常捕获
    Jquery 扩展方法
    Spring.NET笔记1
    ASP.NET MVC Ninject 实现依赖注入
    ASP.NET MVC Unity实现依赖注入
    windows service
    反射用法
    抽象工厂核心反射
    (C#)中的DataSet、string、DataTable等对象转换成Json
    .NET批量删除代码前的行号
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3711444.html
Copyright © 2020-2023  润新知