UITextField in a UITableViewCell
http://stackoverflow.com/questions/409259/having-a-uitextfield-in-a-uitableviewcell
http://stackoverflow.com/questions/7034433/how-to-get-uitextfield-values-when-button-is-clicked
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableLogin dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if ([indexPath section] == ) {
UITextField *textfield = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
textfield.adjustsFontSizeToFitWidth = YES;
textfield.textColor = [UIColor blackColor];
textfield.backgroundColor = [UIColor whiteColor];
textfield.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
textfield.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support
textfield.textAlignment = UITextAlignmentLeft;
textfield.clearButtonMode = UITextFieldViewModeNever; // no clear 'x' button to the right
textfield.delegate = self;
if ([indexPath row] == ) {
textfield.tag = ;
textfield.placeholder = @"your username";
textfield.keyboardType = UIKeyboardTypeDefault;
textfield.returnKeyType = UIReturnKeyNext;
}
else {
textfield.tag = ;
textfield.placeholder = @"required";
textfield.keyboardType = UIKeyboardTypeDefault;
textfield.returnKeyType = UIReturnKeyDone;
textfield.secureTextEntry = YES;
}
[textfield setEnabled:YES];
[cell addSubview:textfield];
[textfield release];
}
}
if ([indexPath section] == ) { // Email & Password Section
if ([indexPath row] == ) { // Email
cell.textLabel.text = @"Email";
}
else {
cell.textLabel.text = @"Password";
}
}
else { // Login button section
cell.textLabel.text = @"Log in";
}
return cell;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
switch (textField.tag) {
case :
self.username = textField.text;
break;
case :
self.password = textField.text;
break;
}
return true;
}
UITextField in a UITableViewCell的更多相关文章
- TableViewCell,TableView,UITableViewCell
这次的学习是在Navigation-based Application模板中,用RootViewController class设置操作方法,使用UITableView的属性值.在导航控制器控件为程序 ...
- 你真的了解UITableViewCell重用吗?
一:首先查看一下关于UITableViewCell重用的定义 - (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentif ...
- UITextField AutoComplete iOS输入框内文本自动完成
当你打开Safari的时候,输入网址,会有许多候选网址,点击后,自动填充到输入框,进入网页. 打开词典查单词的时候,输入前面部分字母,软件会给出符合的候选单词. 这样做的目的,是为了省去用户繁琐的输入 ...
- Swift - 给表格的单元格UITableViewCell添加图片,详细文本标签
表格UITableView中,每一单元格都是一个UITableViewCell.其支持简单的自定义,比如在单元格的内部,添加图片和详细文本标签. 注意UITableViewCell的style: (1 ...
- UITableView中cell里的UITextField不被弹出键盘挡住
UITableView中cell里的UITextField不被弹出键盘挡住 本人视频教程系类 iOS中CALayer的使用 效果如下: 源码: EditCell.h 与 EditCell.m // ...
- UITextField
UITextFieldDemo 效果 特点 1.有效定制键盘的样式 2.处理键盘对文本框的遮挡 用法 1.导入文件(UITextField+CreateInputAccessoryView.h/.m) ...
- UITableViewCell定制
UITableViewCell定制 效果 特点 1.可以添加不同的TableViewCell,可以定制不同的cell样式; 2.可以动态改变cell的高度; 3.可以随意摆放你cell的位 ...
- 自定义UITableViewCell实现左滑动多菜单功能LeftSwipe
今天愚人节,小伙们,愚人节快乐! 实现一个小功能,滑动菜单,显示隐藏的功能菜单, 先上图: 这里尝试用了下使用三个方式来实现了这个功能: 1.使用自定义UI ...
- 【ios开发】UITableViewCell的重用
移动开发需要解决的一个问题就是资源稀缺的问题.多数情况下是内存问题. 虽然现在的手机都号称大内存,高配置.但是移动app所占用的资源也在跟着不断膨胀, 也是造成内存不足的主要原因. 在前面的例子中,还 ...
随机推荐
- Entity Framework应用:导航属性
一.主键和外键 关系型数据库中的一条记录中有若干个属性,若其中某一个属性组是能唯一标识一条记录,该属性组就可以称为主键.例如: 学生版(学号.姓名.性别.班级) 其中每个学生的学号是唯一的,学号就是一 ...
- Graph-BFS-Fly-图的广度优先遍历-最小转机问题
#include <iostream> #include <queue> using namespace std; /* 5 7 1 5 1 2 1 3 2 3 2 4 3 4 ...
- webpack1--安装与初始化
webpack可用于打包所有的脚本,图片,样式表及其他资源. 今天来讲一下如何安装webpack 及 创建package.json.webpack依赖于npm和 node,所以本文是假设你已安装好了n ...
- San初步使用
考虑使用这个玩意只有两个理由: 组件反解.可以让服务端模板渲染首屏,随后由框架接手控制. 从IE7(作者在评论中有提到)开始支持. 在改造老项目上特别吸引人,只需要移除哪些繁杂的dom操作由m ...
- Netty实践
Netty是JBOSS针对网络开发的一套应用框架,它也是在NIO的基础上发展起来的.netty基于异步的事件驱动,具有高性能.高扩展性等特性,它提供了统一的底层协议接口,使得开发者从底层的网络协议(比 ...
- HOW-TO GEEK SCHOOL
This How-To Geek School class is intended for people who want to learn more about security when usin ...
- Linux source命令
Linux source命令 Linux source命令: 通常用法:source filepath 或 . filepath 功能:使当前shell读入路径为filepath的shell文件并 ...
- android 获取配置文件 相对路径
--src --com.example.Demo1 --IndexActivity.class --test.txt 在IndexActivity.class 获取test.txt中的文件 ...
- JAVA中如何用接口实现多继承和多态 (非常好)
---------------------------------------------------------------多态1.JAVA里没有多继承,一个类之能有一个父类.而继承的表现就是多态. ...
- android WiFi ASSOC_REJECT 流程跟踪
Android设备在于AP关联时,如果AP返回关联拒绝帧,Android设别会把AP加入黑名单中. 黑名单中的设备将会在扫描时,延时一段时间放在后面处理. 代码以及log基于SDM450, Andro ...