Search code examples
ios5uitableviewsubviews

UITableViewCell from contentView subview


I have created the cells with labels and using checkaMarksAccessory. The few last cells have UITextFields which can user modifi, and those have selector on UIControlEventEditingDidEnd where i want change the state of the cell to checked.

How can i get the cell in the selector? Doesn't have the object some parentView?

The way i inserting the object to cell.

    UITextField *textfield = [[UITextField alloc] initWithFrame:CGRectMake(10, 25, 200, 30)];
    [textfield setBorderStyle:UITextBorderStyleRoundedRect];
    [textfield addTarget:self action:@selector(vybavaDidFinishEdit:) forControlEvents:UIControlEventEditingDidEnd];
    [cell.contentView addSubview:textfield];

Solution

  • ok so the way is to use superview. The superview is component which own the object. If i want get the UITableViewCell from UITextField i used [[UITextField superview] superview].