http://blog.d-17.com/2009/10/combining-multiple-uitextfields-and-a-uitableview-in-a-nice-way-for-an-iphone-app-part-2/
https://github.com/breeno/EditingUITableView
Write down this statement to the cellforrowatindexPath method of tableview and it will work now.
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];
Example......
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(140.0, 12.0,170.0, 25.0)];
textField.borderStyle = UITextBorderStyleNone;
//yes strange, but otherwise the textfield won't show up :(
cell.textLabel.backgroundColor = [UIColor blackColor];
textField.tag=indexPath.row;
//textField.text = [NSString stringWithFormat:@"value %i", indexPath.row];
textField.placeholder= [NSString stringWithFormat:@"value %i", indexPath.row];
[textField setDelegate:self];
//[textField addTarget:self action:@selector(textFieldDone:)
// forControlEvents:UIControlEventEditingDidEndOnExit];
[cell.contentView addSubview:textField];
[textField release];
cell.textLabel.text = [NSString stringWithFormat:@"Item %i", indexPath.row];//[questionsArray objectAtIndex:indexPath.row];
textField.returnKeyType=UIReturnKeyNext;
if (indexPath.row==6) {
textField.returnKeyType=UIReturnKeyDone;
}
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;// autorelease];
}
https://github.com/breeno/EditingUITableView
Write down this statement to the cellforrowatindexPath method of tableview and it will work now.
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];
Example......
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(140.0, 12.0,170.0, 25.0)];
textField.borderStyle = UITextBorderStyleNone;
//yes strange, but otherwise the textfield won't show up :(
cell.textLabel.backgroundColor = [UIColor blackColor];
textField.tag=indexPath.row;
//textField.text = [NSString stringWithFormat:@"value %i", indexPath.row];
textField.placeholder= [NSString stringWithFormat:@"value %i", indexPath.row];
[textField setDelegate:self];
//[textField addTarget:self action:@selector(textFieldDone:)
// forControlEvents:UIControlEventEditingDidEndOnExit];
[cell.contentView addSubview:textField];
[textField release];
cell.textLabel.text = [NSString stringWithFormat:@"Item %i", indexPath.row];//[questionsArray objectAtIndex:indexPath.row];
textField.returnKeyType=UIReturnKeyNext;
if (indexPath.row==6) {
textField.returnKeyType=UIReturnKeyDone;
}
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;// autorelease];
}
No comments:
Post a Comment