如何在iphone的tableview中创建文本字段?
我想知道如何在iphone的tableview中创建文本字段 这意味着如何在uiTableviewCell上添加uitextfield以及如何处理它 为了处理表示在提交时响应it委托和获取值的方法…查找以下链接 或者试试这个如何在iphone的tableview中创建文本字段?,iphone,ipad,uitableview,Iphone,Ipad,Uitableview,我想知道如何在iphone的tableview中创建文本字段 这意味着如何在uiTableviewCell上添加uitextfield以及如何处理它 为了处理表示在提交时响应it委托和获取值的方法…查找以下链接 或者试试这个 - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [table
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"];
if( cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];
cell.textLabel.text = [[NSArray arrayWithObjects:@"First",@"Second",@"Third",@"Forth",@"Fifth",@"Sixth",@"Seventh",@"Eighth",@"Nineth",@"Tenth",nil]
objectAtIndex:indexPath.row];
if (indexPath.row % 2) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 21)];
textField.placeholder = @"Enter Text";
textField.text = [inputTexts objectAtIndex:indexPath.row/2];
textField.tag = indexPath.row/2;
textField.delegate = self;
cell.accessoryView = textField;
[textField release];
} else
cell.accessoryView = nil;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
创建UITextView或UTextField的实例,并将其作为子视图添加到UITableViewCell中。在
CellForRowAtIndexPath:
UITextField *textField = [UITextField alloc] initWithFrame:CGRectMake(0,0,50,50)];
cell.contentView =textField;
[textField release];
在定制部分
UITextField *textField = [[cell contentView] viewWithTag:1000];
textField.text = @"Your text";
@首先,如果您只想在tableview中添加textfield,那么他正在编写。是否可以在此处添加多个textfield
UITextField *textField = [[cell contentView] viewWithTag:1000];
textField.text = @"Your text";