2009-06-17 54 views

回答

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) 
    { 

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

因此,如果我们做出了改变,我们可以把它做你想做的事:

- (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 2009-06-19 02:35:45

相关问题