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的更多相关文章

  1. TableViewCell,TableView,UITableViewCell

    这次的学习是在Navigation-based Application模板中,用RootViewController class设置操作方法,使用UITableView的属性值.在导航控制器控件为程序 ...

  2. 你真的了解UITableViewCell重用吗?

    一:首先查看一下关于UITableViewCell重用的定义 - (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentif ...

  3. UITextField AutoComplete iOS输入框内文本自动完成

    当你打开Safari的时候,输入网址,会有许多候选网址,点击后,自动填充到输入框,进入网页. 打开词典查单词的时候,输入前面部分字母,软件会给出符合的候选单词. 这样做的目的,是为了省去用户繁琐的输入 ...

  4. Swift - 给表格的单元格UITableViewCell添加图片,详细文本标签

    表格UITableView中,每一单元格都是一个UITableViewCell.其支持简单的自定义,比如在单元格的内部,添加图片和详细文本标签. 注意UITableViewCell的style: (1 ...

  5. UITableView中cell里的UITextField不被弹出键盘挡住

    UITableView中cell里的UITextField不被弹出键盘挡住 本人视频教程系类   iOS中CALayer的使用 效果如下: 源码: EditCell.h 与 EditCell.m // ...

  6. UITextField

    UITextFieldDemo 效果 特点 1.有效定制键盘的样式 2.处理键盘对文本框的遮挡 用法 1.导入文件(UITextField+CreateInputAccessoryView.h/.m) ...

  7. UITableViewCell定制

    UITableViewCell定制 效果       特点 1.可以添加不同的TableViewCell,可以定制不同的cell样式; 2.可以动态改变cell的高度; 3.可以随意摆放你cell的位 ...

  8. 自定义UITableViewCell实现左滑动多菜单功能LeftSwipe

    今天愚人节,小伙们,愚人节快乐! 实现一个小功能,滑动菜单,显示隐藏的功能菜单, 先上图:                       这里尝试用了下使用三个方式来实现了这个功能: 1.使用自定义UI ...

  9. 【ios开发】UITableViewCell的重用

    移动开发需要解决的一个问题就是资源稀缺的问题.多数情况下是内存问题. 虽然现在的手机都号称大内存,高配置.但是移动app所占用的资源也在跟着不断膨胀, 也是造成内存不足的主要原因. 在前面的例子中,还 ...

随机推荐

  1. Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

    vi /etc/environment add these lines... LANG=en_US.utf-8 LC_ALL=en_US.utf-8 QQ技术交流群:576269252 ------- ...

  2. R语言使用RMySQL连接及读写Mysql数据库 测试通过

    R语言使用RMySQL连接及读写Mysql数据库 简单说下安装过程,一般不会有问题,重点是RMySQL的使用方式. 系统环境说明 Redhat系统:Linux 460-42.6.32-431.29.2 ...

  3. 安装Cocos2d-x3.0步骤

    一.在Windows环境下安装 二.在Mac环境下安装 首先,安装brew工具,参照官方网:http://brew.sh/index_zh-cn.html Cocos2d-x3.0需要安装NDK,SD ...

  4. Unity如何内置Visual Studio

    一.问题的起源 软件环境:Unity 2017.3.0f3,Visual Studio 2013 问题描述:在Unity中创建C#脚本后,准备双击打开进行编辑时,出现了Fatal Error. 二.问 ...

  5. Mybatis set标签

    set - 更新语句 当 update 语句中没有使用 if 标签时,如果有一个参数为 null,都会导致错误. 当在 update 语句中使用if标签时,如果前面的if没有执行,则或导致逗号多余错误 ...

  6. linux网络配置练习

    查看网卡是否正常安装 命令:lspci |grep Ether 1.修改网卡配置 命令: vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth ...

  7. MYSQL的索引类型:PRIMARY, INDEX,UNIQUE,FULLTEXT,SPAIAL 有什么区别?各适用于什么场合?

    一.介绍一下索引的类型 Mysql常见索引有:主键索引.唯一索引.普通索引.全文索引.组合索引PRIMARY KEY(主键索引) ALTER TABLE `table_name` ADD PRIMAR ...

  8. phd文献阅读日志-博一上学期

    为了记住并提醒自己阅读文献,进行了记录(这些论文都是我看过理解的),论文一直在更新中. 博一上学期: 1.week 6,2017.10.16 2014-Automatic Semantic Model ...

  9. idea出现插件突然失灵解决方案

    File -> Settings  -> Plgins  把失效的插件重新去掉打钩并重新打钩即可

  10. Java多线程——Lock&Condition

    Lock比传统线程模型中的synchronized方式更加面向对象,与生活中的锁类似,锁本身也应该是一个对象.两个线程执行的代码片段要实现同步互斥的效果,它们必须用同一个Lock对象. package ...