iOS_UITextField 基本操作
基本操作
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 基本操作的更多相关文章
- Key/Value之王Memcached初探:二、Memcached在.Net中的基本操作
一.Memcached ClientLib For .Net 首先,不得不说,许多语言都实现了连接Memcached的客户端,其中以Perl.PHP为主. 仅仅memcached网站上列出的语言就有: ...
- Android Notification 详解(一)——基本操作
Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...
- Android Notification 详解——基本操作
Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...
- 三、Redis基本操作——List
小喵的唠叨话:前面我们介绍了Redis的string的数据结构的原理和操作.当时我们提到Redis的键值对不仅仅是字符串.而这次我们就要介绍Redis的第二个数据结构了,List(链表).由于List ...
- 二、Redis基本操作——String(实战篇)
小喵万万没想到,上一篇博客,居然已经被阅读600次了!!!让小喵感觉压力颇大.万一有写错的地方,岂不是会误导很多筒子们.所以,恳请大家,如果看到小喵的博客有什么不对的地方,请尽快指正!谢谢! 小喵的唠 ...
- 一、Redis基本操作——String(原理篇)
小喵的唠叨话:最近京东图书大减价,小喵手痒了就买了本<Redis设计与实现>[1]来看看.这里权当小喵看书的笔记啦.这一系列的模式,主要是先介绍Redis的实现原理(可能很大一部分会直接照 ...
- Linq查询基本操作
摘要:本文介绍Linq查询基本操作(查询关键字) - from 子句 - where 子句 - select子句 - group 子句 - into 子句 - orderby 子句 - join 子句 ...
- C++ map的基本操作和使用
原文地址:http://blog.sina.com.cn/s/blog_61533c9b0100fa7w.html Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可 ...
- python之最强王者(10)———文件(File)、输入输出的基本操作
1. Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 2.打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式. ...
随机推荐
- 115道Java经典面试题(面中率最高、最全)
115道Java经典面试题(面中率最高.最全) Java是一个支持并发.基于类和面向对象的计算机编程语言.下面列出了面向对象软件开发的优点: 代码开发模块化,更易维护和修改. 代码复用. 增强代码的可 ...
- 一个简单有效的kubernetes部署案例
部署web-rc:web应用需要去获取redis注入的ip环境变量cluster_ip,以此来访问 [root@sdw1 files]# cat testweb-rc.yaml kind: Repli ...
- android开发(42) 使用andorid操作蓝牙打印机
最近接到一个需求,使用android发起打印任务,通过蓝牙连接打印机.条件如下: 打印机:南京富士通DPK760E,具有蓝牙功能 Android手机:普通手机,Android 4.4版本,具有蓝牙功能 ...
- aps.net MVC view 判断方法
两种方式 1.使用Razor 视图 新建app_code文件夹(在这个目录下ShowHelper.cshtml会自动编译成类,方法必须都是静态的) @functions{ //是否显 public s ...
- 线段树 + 区间更新 + 模板 ---- poj 3468
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 59798 ...
- jq 智能搜索
案例:http://www.runoob.com/jqueryui/example-autocomplete.html <input type="text" style=& ...
- The SDK platform-tools version ((23)) is too old to check APIs compiled with API 26;
好像是更新过啥SDK之后,项目一直在包名的那一行显示红线,不过是不报编译错误的,就是看着老扎心老扎心的,开始以为是指定的SDK版本的问题,修改后发现无效,最后找到方法解决: 打开SDK Manager ...
- numpy的排序
- windows sever2003安装Wamp 2.5不成功——VC 11不支持Windows Server 2003和win XP?
Windows Server 2003 安装Wamp 2.5不成功Wampserver 2.5 will not run on Windows XP 报错信息:C:\wamp\bin\apache\a ...
- MongoDB多文档查询
db.getCollection('transactionCompensation').find( { "$and":[ { "status":{ " ...