2011-11-16 59 views
1

在编辑,调整大小或正确移动标签和图像时,如何缩进我的CUSTOM CELL编辑时缩进UITableViewCell

我用:

- (BOOL) tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 

没有影响。

有什么想法?

回答

1

解决了动画的所有组件以这种方式(改变frame.origin.x):

- (BOOL) tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:.3]; 

    [cell.CellTitle setFrame:cgrectMake(x+20, y, w, h)]; // +x 
    [...] 
    [cell.CellAddress setFrame:f2]; 

    [UIView commitAnimations]; 

    return YES; 
} 

上编辑/保存动画“缩进”控制左侧或右侧。

谢谢

+0

虽然这可能会工作,我会去与jbat100的解决方案,并避免完全写这个代码。 – nmdias

6

我不知道我是否理解你的问题,但是如果你希望你的单元格内容在编辑模式下进行切换时正确缩进,那么你应该把所有的单元格子视图放在UITableViewCell contentView中,这是讨论:

UITableViewCell对象的内容视图是由单元显示的内容的默认超级视图 。如果要通过 简单添加其他视图来自定义单元格,则应将它们添加到内容 视图中,以便在单元格转换为 进入和退出编辑模式时它们将被正确定位。

如果您正确设置了自动调整大小的掩码,那么所有大小调整都应该正确。