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所占用的资源也在跟着不断膨胀, 也是造成内存不足的主要原因. 在前面的例子中,还 ...
随机推荐
- 虚拟机安装以及PCL的配置(1)
安装虚拟机 (1) 下载VMware安装(自己百度一下,会有很多可供下载的) (2) 安装方式: 双击,一路点击next,不用更改安装路径(当然你也可以更改),选择安装“典型”即可 接着就有安 ...
- 图示 Smart-Art
在PPT中,图示有两个作用,一是将对象间的逻辑关系视觉化,使文字承载的信息一目了然; 二是打破呆板的页面版式,让枯燥的文本变得更有魅力. 比较聪明的办法是在Sma吨Art生成图形的基础上继续编辑,使其 ...
- http代理和SOCKS5代理的区别
HTTP代理:能够代理客户机的HTTP访问,主要是代理浏览器访问网页,它的端口一般为80.8080.3128等:SOCKS代理:SOCKS代理与其他类型的代理不同,它只是简单地传递数据包,而并不关心是 ...
- Google File System 学习
摘要 Google的人设计并实现了Google File System,一个可升级的分布式文件系统,用于大的分布式数据应用.可以运行在廉价的日用硬件上,具备容错性,且为大量客户端提供了高聚合的性能. ...
- C语言中头文件——你乱吗????
如果尔等之辈问本大神,为什么需要头文件呢?本大神告诉你:想要知道为什么需要头文件的话,你就应该知道C语言编译的过程: 本大神为你们准备了基本知识: C语言文件的编译与执行的四个阶段并分别描述: C++ ...
- Java如何比较两个数组?
在Java中,如何比较两个数组? 示例 以下示例使用equals方法来检查两个数组是否相等. package com.yiibai; import java.util.*; public class ...
- Java数组列表反转
在Java中,如何反转数组列表中的元素? 以下示例使用Collections.reverse(ArrayList)方法反转数组列表中的元素. package com.yiibai; public cl ...
- POJ 3481 Double Queue(STL)
题意 模拟银行的排队系统 有三种操作 1-加入优先级为p 编号为k的人到队列 2-服务当前优先级最大的 3-服务当前优先级最小的 0-退出系统 能够用stl中的map 由于map本身 ...
- SpringMVC文件上传基础
maven依赖 <!--文件上传所需--> <dependency> <groupId>commons-fileupload</groupId> < ...
- 运行 Shell 脚本有两种方法:
1.作为可执行程序 将上面的代码保存为 test.sh,并 cd 到相应目录: chmod +x ./test.sh #使脚本具有执行权限 ./test.sh #执行脚本 注意,一定要写成 ./tes ...