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所占用的资源也在跟着不断膨胀, 也是造成内存不足的主要原因. 在前面的例子中,还 ...
随机推荐
- 根据map键值对,生成update与select语句,单条执行语句
方法 constructUpdateSQL private static String constructUpdateSQL(String tableName, List<Map<Stri ...
- 企业私有云部署im,视频服务
1,安全问题 2,员工跨地域 3,内部视频培训 考勤申请,设备借用申请 名片申请 会议室预订 审批 内网,局域网部署 Android源码 https://github.com/starrtc/andr ...
- 引用dataframe的值为什么会不同
在R语言中,通常有一些操作符可以来提取对象的子集,如以下三种: 1.“[” 单层方括号,返回的对象与原对象类型相同,它也可以返回一个对象中的多个元素: 2.“[[” 双层方括号,用来从列表(list) ...
- C语言课程设计-保安值班系统支持任意输入保安值班时间
//.cpp : Defines the entry point for the console application. // #include "string.h" #incl ...
- JUnit注解
在本节中,我们将提到支持在JUnit4基本注释,下表列出了这些注释的概括: 注解 描述 @Testpublic void method() 测试注释指示该公共无效方法它所附着可以作为一个测试用例. @ ...
- Java中的Swing及AWT又称GUI编程
Java中的Swing及AWT又称GUI编程. 关于学习Java要不要学Swing及AWT,这个完全取决于个人的开发及发展方向. 如果从事web方向的开发,则可以不用学习Swing及AWT. 如果从事 ...
- webpy 使用python3开发
由于做服务器时总是需要调式与客户端的各种协议,由于种种原因客户端总是滞后的.所以一直想做个协议调试工具.postman是一个好东西,不过如果前后协议之间有关联,就不是很好用了. 之前用python写过 ...
- (原)tslib的交叉编译
今天准备重新来交叉编译qt5.3.1的源码,由于按网上说的,需要先编译tslib,所以拿起来之前的编译源码,打算重新用新的交叉编译工具再次编译一次,在查找资料的过程中浪费了些许时间.其实直接就在使用s ...
- .net framework 4.0上跑webapi 1.0
public static class WebApiConfig { public static void Register(HttpConfiguration config) { // Web AP ...
- C# WinForm下,隐藏主窗体的方法
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...