2009-06-17 5 views

Répondre

2

Un extrait d'un Matt Gallagherblog post révèle une méthode

Ceci est le code d'origine pour imiter le comportement que vous NE VOULEZ PAS:

- (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]; 
} 

Donc, si nous avons fait un changement, nous pouvons le faire faire ce que vous voulez:

- (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]; 
} 

vous proabably devez modifier, mais il est un bon début.

+0

merci, et je vais essayer. – Zteeth

Questions connexes