基本操作

UITextField *userNameTextField = [[UITextField alloc] init];
userNameTextField.frame = CGRectMake(30, 100, 220, 50);
[self.window addSubview:userNameTextField];
[userNameTextField release]; // 设置样式
userNameTextField.borderStyle = UITextBorderStyleRoundedRect;
userNameTextField.placeholder = @"Enter your name";
userNameTextField.text = @"OUTLAN"; userNameTextField.clearButtonMode = UITextFieldViewModeWhileEditing; // 设置右边删除button出现时间 UILabel *leftLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
leftLable.text = @"N";
// 设置左右视图的显示时间
userNameTextField.leftView = leftLable;
userNameTextField.leftViewMode = UITextFieldViewModeAlways;
[leftLable release]; userNameTextField.enabled = YES; // 设置是否同意输入
userNameTextField.clearsOnBeginEditing = NO; // 输入时清空
userNameTextField.secureTextEntry = NO; // 呈现圆点,一般用于输入password userNameTextField.keyboardAppearance = UIKeyboardAppearanceDark; // 控制键盘颜色为黑
userNameTextField.keyboardType = UIKeyboardTypeEmailAddress; // 设置键盘样式
userNameTextField.returnKeyType = UIReturnKeySearch; // 设置return按键的样式 UIView *keyBoard = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 300)]; keyBoard.backgroundColor = [UIColor greenColor];
// userNameTextField.inputView = keyBoard; // 替换键盘
[keyBoard release]; UIView *inputAccessView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 20)];
inputAccessView.backgroundColor = [UIColor yellowColor];
userNameTextField.inputAccessoryView = inputAccessView; // 辅助条
[inputAccessView release];

收回键盘

设置代理对象。通常为self

// 设置代理
textFiled.delegate = self;

当前类遵守协议

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITextFieldDelegate>

实现协议方法

  - (BOOL)textFieldShouldReturn:(UITextField *)textField
{
NSLog(@"点击了Return");
[textField resignFirstResponder]; // 放弃第一响应者 收回键盘
return YES;
} - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
NSLog(@"begining");
return YES;
} - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
NSLog(@"ending");
return YES;
}

iOS_UITextField 基本操作的更多相关文章

  1. Key/Value之王Memcached初探:二、Memcached在.Net中的基本操作

    一.Memcached ClientLib For .Net 首先,不得不说,许多语言都实现了连接Memcached的客户端,其中以Perl.PHP为主. 仅仅memcached网站上列出的语言就有: ...

  2. Android Notification 详解(一)——基本操作

    Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...

  3. Android Notification 详解——基本操作

    Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...

  4. 三、Redis基本操作——List

    小喵的唠叨话:前面我们介绍了Redis的string的数据结构的原理和操作.当时我们提到Redis的键值对不仅仅是字符串.而这次我们就要介绍Redis的第二个数据结构了,List(链表).由于List ...

  5. 二、Redis基本操作——String(实战篇)

    小喵万万没想到,上一篇博客,居然已经被阅读600次了!!!让小喵感觉压力颇大.万一有写错的地方,岂不是会误导很多筒子们.所以,恳请大家,如果看到小喵的博客有什么不对的地方,请尽快指正!谢谢! 小喵的唠 ...

  6. 一、Redis基本操作——String(原理篇)

    小喵的唠叨话:最近京东图书大减价,小喵手痒了就买了本<Redis设计与实现>[1]来看看.这里权当小喵看书的笔记啦.这一系列的模式,主要是先介绍Redis的实现原理(可能很大一部分会直接照 ...

  7. Linq查询基本操作

    摘要:本文介绍Linq查询基本操作(查询关键字) - from 子句 - where 子句 - select子句 - group 子句 - into 子句 - orderby 子句 - join 子句 ...

  8. C++ map的基本操作和使用

    原文地址:http://blog.sina.com.cn/s/blog_61533c9b0100fa7w.html Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可 ...

  9. python之最强王者(10)———文件(File)、输入输出的基本操作

    1. Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 2.打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式. ...

随机推荐

  1. oracle快速创建可用用户

    执行语句 create user utaptest identified by utaptest; create tablespace utaptestspace datafile 'd:\data. ...

  2. 初试 spring web mvc

    作为一名code需要了解更多的知识,编程方面的东西太多了,是个逐渐积累的过程.最近学习一下spring web mvc,写下我个人的一些经验. 1.准备jar包.spring mvc 已经到了版本4, ...

  3. openvpn之client配置篇

    对于client端,其配置目录文件下有如下文件: [root@localhost client1]# ll total -rw-r--r-- nobody nobody Sep ca.crt -rw- ...

  4. openh264 api 使用

    IS_PARAMETER_SET_NAL:是不是参数集nal 头文件codec_api.h codec_app_def.h codec_def.h codec_ver.h SEncParamExt.i ...

  5. php时间段判断

    <?php function times(){ ini_set('date.timezone','Asia/Shanghai'); $time = date("Y-m-d H:i&qu ...

  6. oracle PLSQL基础学习

    --oracle 练习: /**************************************************PL/SQL编程基础************************** ...

  7. 【转】【Python】Python3爬虫实现自动登录、签到

    工具:Fiddler 首先下载安装Fiddler,这个工具是用来监听网络请求,有助于你分析请求链接和参数. 打开目标网站:http://www.17sucai.com/,然后点击登录 好了,先别急着登 ...

  8. hibernate+spring整合增删改事务错误

    org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read ...

  9. mysql监控工具sqlprofiler,类似sqlserver的profiler工具

    最近无意发现了mysql的客户端监控工具“Nero Profile SQL”,刚开始还不知道怎么使用,经过半小时摸索,现将使用步骤写下来. 背景:开发的时候,如果数据存储层这块使用EF,或者其他orm ...

  10. adv7180驱动

    http://download.csdn.net/download/u013308744/9945184 http://www.ebaina.com/bbs/thread-10121-1-1.html ...