2009-06-17 1 views
1

タイトルとして、UITableViewCellEditingStyleDeleteボタン/アイコンをグループ化されたテーブルビューのtableviewcell内に配置することはできますか?グループ化されたテーブルビュー内にUITableViewCellEditingStyleDeleteアイコンを配置する良い方法はありますか?

- (void)setEditing:(BOOL)editing animated:(BOOL)animated 
{ 
    [self setNeedsLayout]; 
} 

- (void)layoutSubviews 
{ 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 

    [super layoutSubviews]; 

    if (((UITableView *)self.superview).isEditing) 
    { 

     CGRect contentFrame = self.contentView.frame; 
     contentFrame.origin.x = EDITING_HORIZONTAL_OFFSET; 
     self.contentView.frame = contentFrame; 
    } 
    else 
    { 
     CGRect contentFrame = self.contentView.frame; 
     contentFrame.origin.x = 0; 
     self.contentView.frame = contentFrame; 
    } 

    [UIView commitAnimations]; 
} 

だから我々は変更を加えた場合、我々はそれを行うことができます。

答えて

2

Matt Gallagherblog postからの抜粋方法

これは、あなたがしたくない動作を模倣するために元のコードであるが明らかにあなたがしたいことをやります:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated 
{ 
    [self setNeedsLayout]; 
} 

- (void)layoutSubviews 
{ 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 

    [super layoutSubviews]; 

    if (((UITableView *)self.superview).isEditing) 
    { 
     //don't resize and and move your frame here 

     CGRect contentFrame = self.contentView.frame; 
     contentFrame.origin.x = 0; 
     self.contentView.frame = contentFrame; 
    } 
    else 
    { 
     CGRect contentFrame = self.contentView.frame; 
     contentFrame.origin.x = 0; 
     self.contentView.frame = contentFrame; 
    } 

    [UIView commitAnimations]; 
} 

あなたはこれを微調整する必要がありますが、それは良いスタートです。

+0

ありがとう、私は試してみましょう。 – Zteeth

関連する問題