1

In my iPhone app, I have a table view.

I want that when the user selects (or basically touches) on the cell of the tableview then he/she should be able to edit the cell contents.

How can I do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216

2 Answers2

3

@PARTH in order to make your UITableView cells editable i suggest u to give textfields to your cell....

eg:- In

-(UITableViewCell *)reuseTableViewCellWithIdentifier:(NSString *)identifier withIndexPath:(NSIndexPath *)indexPath {


    CGRect cellRectangle = CGRectMake (0, 10, 300, 70); 
    CGRect Field1Frame = CGRectMake (10, 10, 290, 70);
    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellRectangle reuseIdentifier:identifier] autorelease];
    UITextField *textField;


    //Initialize Label with tag 1.

    textField = [[UITextField alloc] initWithFrame:Field1Frame];

    textField.tag = 1;
    [cell.contentView addSubview:textField];

[textField release];
    return cell;
}

and in your cellForRowAtIndexPath method // Configure the cell.

 UITextField *txtTemp = (UITextField *)[cell.contentView viewWithTag:1];

use this where u want in your tableview accordingly otherwise hide it.....Hope it will help u!!

Sudhanshu
  • 3,950
  • 1
  • 19
  • 18
0

you need to put text field inside the table cell use this link.

Community
  • 1
  • 1
Ishu
  • 12,797
  • 5
  • 35
  • 51