views:

54

answers:

1

Hello everybody. I am using DTGridView with a subclass of DTGridViewCell with a UILabel and UITextField to do an in-place cell editing. That idea worked for me in UITableView like this:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    EditableDetailCell *cell = (EditableDetailCell *)[tableView cellForRowAtIndexPath:indexPath];

    [[cell textField] setFrame:CGRectMake(8, 0, cell.frame.size.width, cell.frame.size.height)];
    [[cell textField] becomeFirstResponder];
    [[cell mylabel] setText: nil];
}

The text disappear and the textfield appears. The same thing doesn't work for me with

- (void)gridView:(DTGridView *)agridView selectionMadeAtRow:(NSInteger)rowIndex 
column:(NSInteger)columnIndex
{
  cell textField] setFrame:CGRectMake(8, 0, cell.frame.size.width, cell.frame.size.height)];
  [[cell textField] becomeFirstResponder];
  [[cell label] setText: nil];
}

Can anyone please help me? Thanks a lot.

A: 

There was a little problem in my question. For the second code I did

MyCustomCell* cell = (MyCustomCell *)[aGridView cellInfoForRow:rowIndex column:columnIndex];

before i make cell changes. That works and respondos to my first question. But now I have a second problem. If I scroll off the selected cell and later came it back to show, then the reused cell shows the content with some problem. Example: textField has not become first responder any more, cell is not selected, and the custom cell is drawn in a different cell. How can I solve that problems?