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语句,你可以给它传递零个或多个用逗号隔开的表达式. ...
随机推荐
- Hibernate执行原生SQL
1.查询指定字段 public List<Object[]> getUseList( Integer index, Integer offset, String state, String ...
- windows10删除开始菜单中的xbox、人脉、邮件等应用
1.右键单击PowerShell,选择“以管理员身份运行” 2.输入下面的命令回车,会列出系统中所有已安装应用列表. Get-AppxPackage -AllUsers 从列表中找到你要卸载的应用,并 ...
- PHP中“==”运算符的安全问题
前言 PHP是一种通用的开源脚本语言,它的语法混合了C,Java,以及Perl等优秀语言的语法.除此之外,它还提供了大量的函数库可供开发人员使用.但是,如果使用不当,PHP也会给应用程序带来非常大的安 ...
- e829. 获得和设置JTabbedPane 的卡片
// To create a tabbed pane, see e828 创建JTabbedPane // Get the index of the currently selected tab in ...
- e832. 从JTabbedPane中移动卡片
To move a tab, it must first be removed and then reinserted into the tabbed pane as a new tab. Unfor ...
- (转)ffmpeg 中 av_read_frame_internal分析
作者: chenwei1983 时间: 2012-3-5 04:21 PM标题: ffmpeg 中 av_read_frame_internal分析 ...
- 在Eclipse中设置进行JNI的头文件编译方法(转 http://blog.csdn.net/mirkerson/article/details/17187109)
这两天在搞NDK开发,JNI的头文件进行编译的时候,要跑到对应的class文件路径下(通常是工程的bin目录),进行编译生成,很是不便,也容易出错,所以考虑在Eclipse中作为外部工具引入,所以便查 ...
- Tomcat5内存简单优化
tomcat版本:apache-tomcat-5.5.28 解压版tomcat 修改catalina.bat文件,在开头添加如下内容: JAVA_OPTS='-Xms1024m -Xmx2048m - ...
- LCL Socket基类
SocketBase类库主要是方便创建Socket客户端和Socket服务端的基础实现. 抽象基类:主要实现创建Socket public abstract class NetworkBase{} 通 ...
- 如何去掉jQWidgets中TreeGrid和Grid右下角的链接
关于如何去掉这个水印,这是官方的说法. 更新了jQWidgets版本,发现在使用过程中发现每次渲染完TreeGrid和Grid后会在表格右下角出现一个www.jqwidgets.com的span标签. ...