문제

I have a custom cell set up in xCode4.6. The cell looks great, until I try to edit/delete a cell. I am using .xib and the table is set to a default style.

So to recap: If I call the onClick function everything still looks great, it's when I call the onDoneClick, that the styling gets all messed up; however, if I were to click the onClick again, the styling looks good again.

Thanks for any help!

Here are the two buttons that call the setEditing.

-(IBAction)onClick:(id)sender
{
editBttn.hidden = true;
doneBttn.hidden = false;
[_tableView setEditing:YES animated:YES];
}

-(IBAction)onDoneClick:(id)sender
{
[_tableView setEditing:NO animated:YES]; 
editBttn.hidden = false;
doneBttn.hidden = true;
}
도움이 되었습니까?

해결책

One simplest solution is all a subview inside the tableviewcell so that in edit mode the alignment wont get change.

Follow this steps: 1. In your custom cell xib add a uiview(subView) and of course your tableviewcell(cell). 2. Add all uicontrols to uiview not in tableviewcell. 3. put in iboutlet of uiview in tableviewcell custom class.

This was for custom cell

now in cellForRowAtIndexPath: add this uiview as subview of cell

NSString *cellIdentifier=@"cell";
                CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
                if (cell == nil) {
                    // Load the top-level objects from the custom cell XIB.
                    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellXIB" owner:self options:nil];  
                    cell = [topLevelObjects objectAtIndex:0];
                    [cell addSubview:cell.subView];
                } 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top